Rule #1: Life is supposed to be fun!

August 23, 2019

Send Client ID to Google Analytics to track EVERY SINGLE visitor

Client ID is the anonymous cookie identifier that Google Analytics assigns to every single browser instance of any given web visitor. It’s how GA calculates the Users metric in views which don’t have the User ID feature enabled.

Sending the Client ID as a Custom Dimension to Google Analytics is absolutely necessary. It’s the only way to get row-by-row reports split by user, and it’s the only way to query for data collected from any anonymous user.

The setup is really simple. You need a Custom Dimension setup in Universal Analytics, and then you simply need to add a new Field to set in your Page View tag (or whatever you want to use to send the data to GA)

1, Create Custom dimension in Google Analytics

Click on admin -> custom dimension

custom-dimension-client-id-google-analytics

Name and choose the type. There are 3 scopes in Google Analytics: hit, session and user. Here, client ID is user scope, which related to each cookies.

custom-dimension-client-id-google-analytics-2

Then click save. After creating the custom dimensions, there will be an associated index number with it. We will use this index number later.

custom-dimension-client-id-google-analytics-3

2, Create a variable in Google Tag Manager

First, you navigate to Google Tag Manager, and create a new variable.

custom-dimension-client-id-google-analytics-3

Then choose custom javascript

custom-dimension-client-id-google-analytics-5

Name that client_id_setter, and input this script

function() {
     // Modify customDimensionIndex to match the index number you want to send the data to
     var customDimensionIndex = 5;
     return function(model) {
          model.set('dimension' + customDimensionIndex, model.get('clientId'));
}
}

custom-dimension-client-id-google-analytics-7

REMEMBER TO CHANGE THE “customDimensionIndex” IN THE CODE TO THE INDEX NUMBER IN CUSTOM DIMENSION. Here, we must change it to 2

Then save.

3, Change Google Analytics variable

Refer to your Google Analytics variable

Click on More setting

Enter as below screenshot

custom-dimension-client-id-google-analytics-8

Then save.

After all changes, you may see the client ID as secondary dimension

Good luck on your Digital Marketing career.

Source: https://www.simoahava.com/gtm-tips/use-customtask-access-tracker-values-google-tag-manager/

Posted in Google Analytics, Tag Manager
Write a comment