Skip to content

Instantly share code, notes, and snippets.

@ivolivares
Created February 20, 2018 17:55
Show Gist options
  • Select an option

  • Save ivolivares/1b773b37645859d1b5c11a12a9e0b7de to your computer and use it in GitHub Desktop.

Select an option

Save ivolivares/1b773b37645859d1b5c11a12a9e0b7de to your computer and use it in GitHub Desktop.
Get client ID (Universal Analytics)
function cidFunction() {
var trackers = ga.getAll();
var i, len, trackerCid;
for (i = 0, len = trackers.length; i < len; i += 1) {
if (trackers[i].get('trackingId') === 'UA-XXXXXXXX-X') {
trackerCid = trackers[i].get('clientId');
}
}
console.log(trackerCid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment