The client_id is a unique identifier utilized by GA4, stored in a cookie named _ga, to track if a user has visited a website multiple times. An example of this id is GA1.2.1839138233.1715355754, where the id starts from the sixth character, post GA1.2.
To retrieve the client_id from GTM, follow these steps:
- Create a 1st Party Cookie type variable with 'Cookie name': _ga.
- Create a Custom JavaScript type variable with the following code:
function() {
return {{COOKIE _ga}}.substring(6);
}
After these steps, the user identifier value can be shared with other tags and platforms, subject to the user's cookie consent.