×
Orchidbox
← Technical

Inject Google Analytics Client ID to All Your Links

[ Updated April 18, 2024 ]

We have been playing with Google Analytics Client ID and found that not many agencies have been using it.

The Client ID can be found in the GA cookie and Client ID is stored on the GA cookie of your website’s actual domain.

Google Analytics stores a unique identifier for every user who visits your site within a first-party cookie. This value, in GA parlance, is called the Client ID, and the name of the cookie is _ga.

Here’s what the entire cookie string looks like, with the actual Client ID bolded:
2139536866.1471456764

Client ID could be extremely useful if you are trying to track a multichannel behaviour:

User clicks on a Display ad, then clicks on an Affiliate link, then sees a Twitter ad, then searches through Google, then converts. You can capture all these separate interactions with Client ID.

Adding this simple JS code to your analytics will enable you to add client ID reference to all your urls.

ga(function(tracker) {
var clientId = tracker.get('clientId');
jQuery(document).ready(function($){
var href = $("a").attr('href') + "&id=" + clientId;
$("a").attr("href", href);
});
});

Once this code is installed, you will be able to filter pages by Client ID.

Feel free to change the code when necessary or get in touch for a code customisation.

You may also like...

Let's Talk