Reputation: 47676
Instead of using google analytics User ID
feature I want to read User Id which ga.js
automatically generates and stores in browser cookies. I want to read this id so I can send it to my server. Is it possible?
Upvotes: 0
Views: 114
Reputation: 30461
You can get the client ID that analytics.js stores in cookies as follows:
ga(function(tracker) {
var clientId = tracker.get('clientId');
});
Here's the page in the documentation that describes how:
https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#getClientId
Note: the clientId
is different from the userId
keep in mind that any time the user clears their cookies, the client ID will change. Do not use it to identify particular users.
Upvotes: 2