Tuesday, November 28, 2023
HomeWeb AnalysisHow to get Google Analytics Client ID!

How to get Google Analytics Client ID!

I think that some of you who have upgraded to Universal Analytics have read articles such as How to display client IDs in Universal Analytics and analyze individual behavior, and have actually tried it. However, some of those who have introduced Google Tag Manager along with the version upgrade to Universal Analytics may have given up without knowing how to display the client ID using GTM. Huh?

We will introduce how to get a client ID while introducing Google Tag Manager.

What is a Client ID? What are the advantages of displaying

A client ID is an ID for linking individual browser browsing in Universal Analytics, and is an ID stored in the cookie of each browser. Universal Analytics judges visits by the same user when this client ID is the same.

However, in universal analytics, there is no standard report that allows you to see the browsing behavior of each user. In order to be able to see the browsing behavior of each user, it becomes necessary to customize the tracking code.

On a site with a very large number of conversions, it is not possible to check individual actions in detail, but for a site of a scale and form where conversions occur only a few times a day, it is possible to extract each converted user and By checking your browsing behavior, you will be able to use it for your next action plan.

Setting method

Google Analytics settings

There is almost nothing to configure here. Only one place, create a custom dimension from “analytics settings”. Select “Custom definition” and “Custom dimension” from the setting items of “Properties”,

  • Name: Client ID
  • Scope: User

Create custom dimensions with information such as After creation, the ID of the custom dimension you just created will be assigned. Make a note of it as it will be used later.

Google Tag Manager settings

Tag Manager requires a lot of configuration. You may want to export the current state and save it so that you can always return to the original state. In addition, the explanation here is for Ver2 Google Tag Manager (Google Tag Manager with a new material design UI), but if you are using Ver1 Google Tag Manager, please read it accordingly. No problem.

Adding “Variables”

Although it is not essential, please add the following variables to make it easier to do the work after this and to make it easier to manage Google Tag Manager.

Variable type Variable name value
constant Google Analytics Tracking ID UA-123456-7
constant Google Analytics Tracker Name My Tracker

For TrackingID, please specify the TrackingID of the Google Analytics property you are actually using. Any value is fine for GoogleAnalyticsTrackerName, but here it is “MyTracker”.

Updating existing Universal Analytics tags

First, let’s change the existing Universal Analytics tag to use the variable created above.

Add the Universal Analytics tag to the Tracking ID section of the settings


, check Set tracker name in advanced settings in other settings , and enter the variable created earlier in the tracker name field


Specify If you have Universal Analytics tags with a Track Type other than Page View (e.g. Event Tracking, E-commerce transaction tags, etc.), please make the same changes to all of them as well.

At this point, nothing should have changed in the data sent to Google Analytics. If so, have you run debug at this point and are you getting the same behavior as before the change? Let’s check (whether the tag has been destroyed).

Add custom HTML tag to get client id

Add a new tag. At the timing of selecting “Custom HTML tag” in product selection and delivering , specify the same conditions as the current Universal Analytics tag is loaded. Enter something like “Universal Analytics – Load Client ID” in the tag name , and enter the following script in the HTML (the content here basically does not need to be changed).

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', '{{GoogleAnalyticsTrackingID}}', 'auto', {'name': '{{GoogleAnalyticsTrackerName}}'});
  ga(function() {
    var tracker = ga.getByName('{{GoogleAnalyticsTrackerName}}');
      'event': 'clientIdLoaded',
      'clientId': tracker.get('clientId')

This script loads the Google Analytics library and creates a Google Analytics tracker using the tracker name you created earlier. After the creation of the Google Analytics tracker is completed, the tracker is acquired and the client ID and event variable are pushed to the dataLayer variable.

Add Variable

Earlier we created a constant variable, but this time we will create a variable using the dataLayer variable.

item set value
Variable type data layer variables
Variable name clientId
data layer variable name clientId
Data layer version Version 2
set default value checked
Default value Unknown

Add Trigger

Create a new trigger for Universal Analytics page tracking. In order to get the client ID during page tracking, the variable “clientId” must be available at the time. The timing at which clientId can be used is managed by the event variable “clientIdLoaded”, so use this.

Now, register the following trigger on the Add Trigger screen.

item set value
Select event custom event
event name clientIdLoaded
Use regular expression match no check
trigger name clientIdLoaded

Updated Universal Analytics pageview tag

There are two places to change: specifying the trigger and specifying custom dimensions.

First, change the trigger from the current one to the trigger clientIdLoaded created above . Now the variable clientId will be valid when this tag is called .

Then under Custom Dimensions within Other Settings , click the Add Custom Dimension button and specify the custom dimension clientId. For the index, enter the id (number) that you wrote down when you first created the custom dimension in Google Analytics, and use the variable for the dimension value .


to save the tag.

operation check

This completes the setup work for registering the client ID in the custom dimension of Google Analytics. Check in Debug mode if the settings are correct. You can check using the debug function of Google Tag Manager, but it is recommended to check the data sent to Google Analytics using the Chrome extension Tag Assistant . Custom dimension parameter names are named “cd1” and “cd2”, so

  • Does the sent data have parameter names such as “cd1” and “cd2”?
  • Is its value the same as the value of the parameter name ‘cid’?

It is OK if you check around. Also, if there are custom Google Analytics tags such as event tracking, check their behavior, and if there are no problems, publish to the production environment and you are done.

For reports on the Google Analytics side, please refer to the original article ( How to display client IDs in Universal Analytics and analyze individual behavior ) to create custom reports. In addition, create a custom report that displays only the client ID of the user who converted, check the client ID of the converted user, narrow down by specifying the client ID in the advanced segment, source of inflow, page viewed, transition order for each page, If you look at the time spent on each page, past visits, etc., you may find effective clues for implementing measures.


This is great news for those who have migrated to Google Tag Manager and didn’t know how to set a client ID, and those who haven’t migrated to Google Tag Manager because they don’t know how to set a client ID. If you are not using Google Tag Manager, why not take this opportunity to migrate?


Leave a reply

Please enter your comment!
Please enter your name here

Recent Posts

Popular Posts

Most Popular

Recent Comments