I'm planning to use Google Analytics Measurement Protocol. I'm currently planning to capture the Client ID (cid) by including it as a URL parameter on some Ajax requests.
I've found that I can expose the Client ID value like this:
var ga_cid;
ga(function(tracker) {
ga_cid = tracker.get('clientId');
});
I'm concerned that this route is poor form as it's polluting the global namespace. However, I've been unable to unearth a more elegant (best practice) solution.
What is the "right" way? Am I overthinking this?