Using the latest analytics.js code (as of today) is there a way through their JS API I can get the session id?
Session ID. Session ID is a random, unique string (GUID) which is scoped to the entire session. This means that all hits of the same session can be queried with the same ID.
Where can I find sessions in Google Analytics? To find out how many sessions your site had in the last 30 days, go to the Audience tab in the left hand column of Google Analytics, then click on Overview, then Sessions.
If you're talking about the client ID, you can get that as follows:
ga(function(tracker) {
var clientId = tracker.get('clientId');
console.log(clientId);
});
Here's where that's stated in the documentation:
https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#getting_the_client_id_from_the_cookie
Keep in mind that the client ID is (usually) stored in a cookie, so if the user clears their cookies, they'll be assigned a new client ID that may not match the one you have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With