Google Analytics assumes it is a new user at each request #124
Open
Description
GA count each request sent from the backend as a new User:
I'm building a chatbot, and each message sent by the user counts as a new user. I really don't get why and everything should be working fine because I set the uid
(user id) and cid
(client id) using a variable corresponding to the device id.
Here is some source code:
const visitor = ua(this.googleAnalyticsVisitor.tid, this.deviceId, {
uid: this.deviceId,
});
visitor.event(
category,
action,
label,
value,
{ p: path }, // See "page path" at https://github.com/peaksandpies/universal-analytics/#event-tracking
(err) => {
if (err) {
this.logger.error(err, 'sendGoogleAnalyticsStatistics:error');
Raven.captureMessage(err, { level: 'error' });
}
},
);
this.logger.debug(JSON.stringify(this.googleAnalyticsVisitor, null, 2), 'sendGoogleAnalyticsStatistics:googleAnalyticsVisitor')
this.logger.info(JSON.stringify(visitor, null, 2), 'sendGoogleAnalyticsStatistics:visitor');
this.logger.info(JSON.stringify({
category,
action,
label,
value,
path,
}, null, 2), 'sendGoogleAnalyticsStatistics:event');
Here are the logs
server 2019-02-12T19:59:55.310Z [StudentSolutionsChatbotAI] debug: [sendGoogleAnalyticsStatistics:googleAnalyticsVisitor] {
server "_queue": [],
server "options": {
server "cookieName": "_ga"
server },
server "_context": {},
server "_persistentParams": {},
server "tid": "UA-89785688-3",
server "cid": "64ae7bcc-ff52-46d5-bfa7-5b6ffc9b264d"
server }
server 2019-02-12T19:59:55.311Z [StudentSolutionsChatbotAI] info: [sendGoogleAnalyticsStatistics:visitor] {
server "_queue": [],
server "options": {
server "uid": "311adf00-11dd-11e9-8b1a-fbc5613ee3c7"
server },
server "_context": {},
server "_persistentParams": {
server "uid": "311adf00-11dd-11e9-8b1a-fbc5613ee3c7"
server },
server "tid": "UA-89785688-3",
server "cid": "64ae7bcc-ff52-46d5-bfa7-5b6ffc9b264d",
server "uid": "311adf00-11dd-11e9-8b1a-fbc5613ee3c7"
server }
---
server 2019-02-12T19:59:49.586Z [StudentSolutionsChatbotAI] debug: [sendGoogleAnalyticsStatistics:googleAnalyticsVisitor] {
server "_queue": [],
server "options": {
server "cookieName": "_ga"
server },
server "_context": {},
server "_persistentParams": {},
server "tid": "UA-89785688-3",
server "cid": "7de72c3c-cea6-4bf9-8e9f-90976850deed"
server }
server 2019-02-12T19:59:49.587Z [StudentSolutionsChatbotAI] info: [sendGoogleAnalyticsStatistics:visitor] {
server "_queue": [],
server "options": {
server "uid": "311adf00-11dd-11e9-8b1a-fbc5613ee3c7"
server },
server "_context": {},
server "_persistentParams": {
server "uid": "311adf00-11dd-11e9-8b1a-fbc5613ee3c7"
server },
server "tid": "UA-89785688-3",
server "cid": "7de72c3c-cea6-4bf9-8e9f-90976850deed",
server "uid": "311adf00-11dd-11e9-8b1a-fbc5613ee3c7"
server }
I don't get why it doesn't work properly.
Metadata
Assignees
Labels
No labels