user2979757 user2979757 - 8 months ago 64
Javascript Question

how to get the Google analytics client ID

When you are creating a new instance of analytics.js by running

ga('create', 'UA-XXXXXXX-Y', {'cookieDomain': 'none'});

GA creates a unique client Id.
I want to fetch this id and use it for my own purposes,
but I can find only setter for this parameter but can't find any getter method to get it.

GA send it later in a parameter called

Does anyone knows how do I get it?


Google does have some documentation on getting the client id.

Looks like this:

ga(function(tracker) {
  var clientId = tracker.get('clientId');

I've used this before, too: