What is Client ID in Google Analytics: A Detailed Setup Guide

icon Get in-depth insights

Modern Data Management Guide

icon Get in-depth insights

Modern Data Management Guide

The Client ID (cid) or Client ID number is a unique identifier for a browser–device pair that helps Google Analytics 4 link user actions on a site. By default, Google Analytics 4 determines unique users using this parameter.

What is Client ID in Google Analytics 4: detailed setup guide

However, what in Google Analytics 4 reports are called users would be worth calling browsers. If you go to a site once through Chrome on your computer, another time from a smartphone, and a third time from your computer but using Firefox, the system will identify you as three different users.

This article was written in 2019 and fully updated in January 2024 to cover client ID in Google Analytics 4 fully.

Why do you need a Client ID?

The cid parameter (google customer id number) helps you identify unique visitors (the accuracy isn’t 100%, but it’s better than nothing) and understand what each of them was doing on your website in specific. With the GA4 clientid you can merge data from Google Analytics 4 and CRM systems and set up end-to-end analytics to understand how your marketing efforts affect real sales online and offline.

Where can i find my client id number?

On the technical side, the Client ID is a cookie that’s stored in the client’s browser and sent with each request to Google Analytics 4.

Cookies are text files that are stored in the browser and used by sites to leave information on the client’s side. For example, in a cookie, you can record the source from which the user came, how many times they’ve visited the site, etc. When a user opens a website, this information will be written in cookies. When visiting the site again, the data from this information is sent in get-requests to the web server. The site sees that a user has already left some information and can interact with it.

Google Analytics 4 generates a unique numeric Client ID for each browser–device pair. When a user visits a site, a Google Analytics 4 tracking code sends this ID along with session data – page address, referral source, language, etc. – to Google Analytics 4.


The Client ID cookie exists for two years. That is, if you go to the same site from the same browser within two years (cookies in Safari have a lifetime of about 7 days), Google Analytics 4 will understand that you’re the same user. Each time you visit, the cookie will be reset to expire two years from the time of your visit. If you don’t visit the site for two years, then visit it again, Google Analytics will consider you a new user. If you clear your cookies or reinstall your browser, then you won’t have the same cid and when you visit a website again, Google Analytics will give you a new identifier.
A cookie with a Client ID looks like this:

GA1.1.904941809.1556093647

  • GA1 is a universal prefix of all cookies in this format.

  • The number 1 indicates the level of the domain: in this case, the top-level domain.

  • All that comes after the second period is the Client ID. The first part is a randomly generated number, and the second part (after the third period) is the creation time of the cid in UNIX format.

How to find out your Client ID number

To view your Google Analytics 4 cookie for a specific site in the Chrome browser, open this site, press the F12 key, go to the Application tab, click on Cookies, and select the desired site from the drop-down list. You’ll see a window similar to this:

Google Analytics cookie in the Chrome browser

Find a cookie named _ga. Everything that comes after the second period is your unique Client ID.

To view your Client ID in Mozilla Firefox, press CTRL + Shift + I and go to the Storage tab.


How to find Client ID in Google Analytics 4

In which Google Analytics 4 report can you see Client ID? 

In the "Explore" -> "User Explorer" report, you can see the IDs of the people who visited your site, as well as the name of the stream, the number of events and sessions, revenue, transactions, and conversions so you can do properly do google ga gid analytics.

Audience –> Statistics on users report

By the way, if you have a lot of events, Google Analytics 4 will enable sampling and the statistics in your reports will be skewed. To avoid this, you can collect raw data with OWOX BI.

Let’s return to the User explorer report. If you click on a specific Client ID, you’ll see more detailed information about this visitor (down to each event in the session):

Google Analytics Statistics on users report

By default, cid is only available in this Google Analytics 4 report. You can add a segment to it, but you cannot add other parameters to this report. To access the Client ID in other Google Analytics 4 reports, you must pass cid as a custom parameter. We will tell you how to do it.

Before proceeding to the description of how to pass Client ID to GA4, I would like to dwell on such a parameter as cardinality . This term defines the number of unique values in the data set (in our case, these are parameter values). A large number of unique values increases the likelihood of (other) rows appearing in GA4 reports. For this reason, Google does not recommend passing parameters with high cardinality (which includes the Client ID) to GA4.

If you rarely access reports in the GA4 interface, work with small web resources, or analyze raw data (Google BigQuery Export, OWOX BI Streaming, etc.), cardinality restrictions will not affect you .


How to get Google Analytics Client ID

How to transfer Client ID to a custom Google Analytics option? When working with Google Analytics Universal, the most optimal way to pass the Client Id to GA was the CustomTask method. Because GA4 does not have a СustomTask method (we hope this is temporary, we miss it very much) we will use JS to read the value of the _ga cookie. To pass a value, we will look at two ways: using GTM and using gtag.js. Let’s consider both options in detail.

Step 1. Create a custom parameter in Google Analytics

Open the Google Analytics 4 admin area. Go to the resource settings and select Custom definitions section:

Custom parameters in Google Analytics

Then click Save:

Save button

As a result, you’ll have a new client_id parameter in your admin panel:

New client_id parameter in your admin panel

Now you need to make sure that each time the user interacts with the site, Client ID’s written to an additional parameter. Weʼll show two configuration options: via Google Tag (gtag.js) or via Google Tag Manager.


Step 2. Send Client ID to Google Analytics 4

Via Google Tag Manager

First, you need to add a new variable. To do this, open the Variables tab and create a Custom JavaScript Variable:

Create a Custom JavaScript Variable


Next, paste the following code into the variable workspace:

function() {
var match = document.cookie.match('(?:^|;)\\s*_ga=([^;]*)'), 
raw = match ? decodeURIComponent(match[1]) : null;
if (raw) { 
match = raw.match(/(\d+\.\d+)$/)
} 
return (match) ? match[1] : null; 
}
The following code into the variable workspace


We need this variable in order to pass the client ID to GA4 as a custom parameter. To do this, select the GA4 configuration tag and add the client_id variable to the User Properties field.

add the client_id variable to the User Properties field


Now, let’s verify Client ID is being captured and sent to GA4 correctly in GTM preview mode. Place your GTM container in Preview mode and review the debug panel, inspect your GA4 config tag and check for User Properties being set with “client_id”

inspect your GA4 config tag and check for User Properties being set with “client_id”


The Google Analytics 4 platform successfully receives the Client ID, as shown in the highlighted orange box (This is how values with scope=users are marked)

The Google Analytics 4 platform successfully receives the Client ID


Now, here's the downside. GA4 forces any numerical fields to be converted into number types, so a Client ID is rewritten as a double. This means it becomes illegible as there are too many decimals and the result is truncated. As a result, the Client Id values look like this (here you can see that the number of digits after the decimal point is less than it should be):

Client Id values


To solve this problem, you should change the value of the Client ID so that GA4 no longer recognizes it as a numeric value. To do this, in our example, we add . to the very end of the Client ID value.

Client ID value


After such simple manipulations with the Client Id value, we can see that the Client ID is no longer truncated in the GA4 interface.

Client ID has the correct value

Congratulations, now the Client ID has the correct value, and you can see these values in the GA4 interface.

Via Google Tag (gtag.js)

Now let's figure out how to do the same using gtag.js. This method will be useful for users who have GA4 analytics code embedded using gtag.js. To get the Client ID, we can use the sample code from GTM:

<!-- Google Analytics -->
function getGAValue() {
    var match = document.cookie.match('(?:^|;)\\s*_ga=([^;]*)'),
        raw = match ? decodeURIComponent(match[1]) : null;
    if (raw) {
        match = raw.match(/(\d+\.\d+)$/)
    }
    return (match) ? match[1] : null;
}
<!-- End Google Analytics -->

We also add any character (in our case, this is  ‘.’) so that GA4 does not truncate the value:

var ga_client_id = getGAValue() + '.';

To set up the transfer of our variable (Client ID) to GA4, you need to add it as user properties (the value of a variable can also be added via the set method) to the Google Analytics code on your site. An example of what your gtag.js code might look like:

<script async src="https://www.googletagmanager.com/gtag/js?id={STREAM_ID}"> </script>

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', '{STREAM_ID}', {
  'user_properties': {
    client_id: ga_client_id
  }
}
  );
</script>

Using the Realtime report or Debug View (recommend installing the extension to track your hits in it) you can check the correctness of the implementation. You can see examples of how to check hits in Debug View or how to display Client ID in a report in the "via Google Tag Manager" block.

Why transfer the Client ID to your CRM?

Using the Client ID, you can track all points of contact with a client – not just their actions on the site – as well as supplement the data in Google Analytics with information about purchases. To do this, you need to transfer the identifier to your internal CRM system – for example, using the order form on the website.

First, create a Client ID field in your CRM to which the data will be transferred. Then ask your developer to add a hidden field for cid to the form on the website. When a person completes this form and gives their name, phone, or email, their Google Analytics identifier will be transmitted to your internal system. By the way, some CRMs have ready-made form designers that allow you to build Client IDs without the help of developers.

Book a demo

Gain clarity for better decisions without chaos

No switching between platforms. Get the reports you need to focus on campaign optimization

Book a demo

Best Practices for Client ID Management

Data Accuracy and Consistency

Ensure that Client IDs are assigned consistently and accurately across all user touchpoints, including website visits, mobile apps, and other digital interactions. Standardize the data collection process to avoid duplication and maintain a uniform approach to tracking users.

Uniqueness and Persistence

Generate unique Client IDs for each user to distinguish individual interactions accurately. Additionally, ensure that Client IDs persist across different sessions and devices, enabling seamless user behavior tracking.

Cross-Device and Cross-Platform Tracking

Implement cross-device and cross-platform tracking to associate the same Client ID with a user's interactions across different devices and channels. This comprehensive view helps understand user journeys and behavior holistically.

User Authentication and User-ID

Encourage users to log in or create accounts to provide additional authentication beyond Client IDs. The User-ID feature in Google Analytics can help associate multiple sessions and devices with the same authenticated user.

Handling Cookie Lifespan

Plan for scenarios where users clear their cookies or when cookies expire. Use local storage or first-party cookies to store essential user information for better tracking continuity.

Book a demo

Lower Adwaste, Save Time, and Grow ROI

Make smart decisions about your campaign optimization faster

Book a demo

Compliance with Data Privacy Regulations

Make sure you are compliant with contemporary data privacy regulations and obtain user consent for data collection and tracking. Respect user preferences and provide opt-out options to comply with GDPR and other privacy laws.

Client ID vs User ID: how to track real user behaviour, not their browsers

In order to do this, Google Analytics has a User ID that helps to link all user actions in different browsers and on different devices. You can read more about options for using the Google Analytics User ID in our articles, Why Link Online Visitors and Offline Buyers and ROPO Effect: How Your Online Marketing Impacts Offline Sales.​

In addition, OWOX BI has its own OWOX User ID. With it, you can merge the actions of users across your sites, even if they aren’t connected by direct links. This information is useful when setting up audiences so as not to show ads to the same people twice. Also, when setting up OWOX server-side tracking, using this ID will help you better identify returning users. That’s how OWOX Server-Side Tracking helped one of our clients to find the real sources of conversions for over 30% of Online Sales.


Hassle-free data analysis and reporting

Easily collect, prepare, and analyze marketing data. Stay on top of your marketing performance

Start Free Trial
Automate your digital marketing reporting

FAQ

Expand all Close all
  • What is a client id number?

    A Google Analytics client ID is a unique alphanumeric code allocated to every visitor or user who accesses a website integrated with Google Analytics 4 tracking. This client ID serves as a distinctive and randomly generated string of characters, playing an importnt role in tracking and identifying individual users.
  • Where is the client ID in GA4?

    Log in to your GA4 account. Go to the Explore section. Click on User Explorer. Within this section, you will find the client ID listed for each individual user Or you can find it in the ga.js tracking code.
  • Can I use the client ID to track conversions in Google Analytics 4?

    Yes, you can use the client ID to track conversions by using the User Explorer report to analyze user behavior before and after a conversion event. This can help you to identify patterns and optimize your conversion funnel.
  • Can I track multiple client IDs for the same user in Google Analytics 4?

    No, GA 4 assigns a new client ID for each session, so it's not possible to track multiple IDs for the same user. However, you can use a User ID to track user-level activity across multiple devices and sessions.

icon Get in-depth insights

Modern Data Management Guide

icon Get in-depth insights

Modern Data Management Guide