How to pass the Google Analytics Cookie ID to Google Analytics without a single line of coding?
Before going ahead with this article, I would like to talk about the benefit of passing Cookie ID to Google Analytics.
As we know, Google Analytics doesn’t have any unique identifier to identify a unique lead or unique user. However, Google provides us with a way to pass a unique ID to Google Analytics. Although we cannot pass Personally identifiable information to Google Analytics, we need to pass some ID. In this case, we will pass the Cookie ID. Google Analytics identifies users on the basis of the cookie ID. Each time they clear their cookies or visit from a different device, they will be regarded as a new/different user and be assigned a new Client ID/Cookie ID. It will be more beneficial if you can pass some ID from your system, like your login ID, which will remain the same for the same user and won’t change like a cookie.
This Cookie or Client ID is attributed to every hit along with a ton of other information such as what type of hit is being sent (pageview, event, etc.), the time the hit was made, etc.
Steps to pass the cookie id to Google Analytics:
- We will need the GTM on the website
- We need to create a custom dimension with any name, here its Cookie ID. The scope of this custom dimension will be “user”. We choose User scope because Users are made up of one or more sessions, sessions are made up of one or more hits, and hits can have one or more products associated with them. Choosing User scope will help us to associate that id to sessions and hits by that user
- We need to create a 1st party cookie variable and capture the Google Analytics cookie. The Google Analytics cookie name is “_ga” which we will capture and pass to the Google Analytics
- We need to use that variable in a page view or event tag as per the requirement
The below video shows the step by step tutorial.