How to Get Client ID to Variable in GTM? | BCS How to Get Client ID to Variable in GTM? | BCSBCS

How to Get Client ID to Variable in GTM?

Google Tag Manager BCS 24 hours ago 11 Views 0 Comments

Update time: January 17, 2025

This article introduces how to get the Client ID as a variable in GTM.

There are many methods:

1st Party Cookie

GA4 will store the Client ID in the first-party Cookie _ga, as follows:How to Get Client ID to Variable in GTM?

In GTM, click「Variables」——「New」——「Choose a variables type to begin setup…」——「1st Party Cookie」,Name it “cookie_ga”, and make the following settings:How to Get Client ID to Variable in GTM?

Then create another variable, click「Variables」——「New」——「Choose a variables type to begin setup…」——「1st Party Cookie」,Name it “Client ID-cookie”, and make the following settings:

How to Get Client ID to Variable in GTM?

Finally, preview and debug to see if this variable Client ID-cookie can obtain the Client ID:

How to Get Client ID to Variable in GTM?

Read More:Explanation of Cookie Values ​​Used by Google Analytics 4

 

gaGlobal

After the GA4 tracking code is loaded, it will be represented as the Client ID in window.gaGlobal.vid, which can be viewed in the browser developer tools:

How to Get Client ID to Variable in GTM?

 

It can be get through custom JavaScript variables. click「Variables」——「New」——「Choose a variables type to begin setup…」——「1st Party Cookie」,Name it “Client ID-gaGlobal“, and make the following settings:

How to Get Client ID to Variable in GTM?

 

Next, preview and debug to see if this variable Client ID-gaGlobal can obtain the Client ID:

How to Get Client ID to Variable in GTM?

Note: gaGlobal will be slow to obtain the Client ID and is not recommended.

customTask

GA4 does not support customTask yet.

 

 

Read More:


If you don't understand, You can leave a comment below.
Like (0)
Post my comment
Cancel comment
Expression Bold Strikethrough Center Italic

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • Website