Update time: January 17, 2025
This section introduces how to Set Client ID to Custom Dimensions(aka:User Properties, User Scope Custom Dimension) in GA4.
Step 1 : Get Client ID
GA4 will store the Client ID in the first-party Cookie _ga, as follows:
In GTM, click「Variables」——「New」——「Choose a variables type to begin setup…」——「1st Party Cookie」,Name it “cookie_ga”, and make the following settings:
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:
For more ways to get Client ID, further reading: How to Get Client ID to Variable in GTM?
Step 2 : Set up Custom Dimensions
Secondly, create a Google Tag: Event Settings variable in GTM and set it in “Google Analytics User Properties” as follows (If you have already created Google Tag: Event Settings, add client_id settings in Property Name):
Name it “Common Event Parameter”.
Next, set the variable Common Event Parameter to the Event Settings Variable in the GA4 basic page tracking code(Note that this setting is in the GA4 base page tracking code.), such as:
Step 3 : Preview and Release
Finally, preview testing and release:
The test is as expected and can be released and data collected.
Read More:
Step 4 : Custom Definitions
This custom dimension also needs to be registered in Custom definitions before it can be used. Create a custom dimension as follows in Custom definitions:
Step 5 : Verify data in Real-time Report
Generally, after 24 hours, we can see the data in GA4, such as: