What is Google Client ID in GA4: Detailed Setup Guide for 2024

GA4 Analytics for Beginners

icon Get in-depth insights

Modern Data Management Guide

icon Get in-depth insights

Modern Data Management Guide

The Client ID (cid) or clientid 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.

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.

Note: this article was written in 2019 and fully updated in June 2024 to cover client ID in Google Analytics 4 in depth.

What is Google Analytics 4 Client ID?

The Google Analytics 4 (GA4) client ID is a unique identifier assigned to each user of your website.

Generated by GA4’s gtag.js, it tracks user interactions across sessions, allowing for detailed analysis of user behavior and engagement. This helps businesses understand their audience better and optimize their marketing strategies accordingly.

Its primary purpose is to uniquely identify users across sessions, enabling detailed tracking and the ability to analyze user behavior and engagement on a website.

How Does the Clientid Work?

The Google Analytics 4 (GA4) client ID is generated by the gtag.js library, it is stored in a first-party cookie on the user’s browser.

The client ID is device and browser-specific, while the user ID enables cross-device and cross-browser tracking to track users comprehensively.

This ID tracks user interactions across multiple sessions, providing a continuous view of user behavior.

Each time a user visits, the client ID ensures their actions are linked to their profile, enabling accurate tracking of their journey.

The client ID allows GA4 to analyze and segment user data effectively. By linking user interactions across different sessions, it helps businesses understand user engagement, identify trends, and optimize their marketing strategies.

This continuous tracking is crucial for generating insights into user behavior, improving user experience, and driving business growth.

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 specifically.

With the GA4 ClientID, you can merge data from Google Analytics 4 with CRM systems and set up end-to-end analytics to understand how your marketing efforts affect real sales online and offline.

What Is my ClientID 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 has existed 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 haven't visited the site for two years, then visit it again, and 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 for 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 ClientID in Google Analytics 4

    There are several options to do that.

    #1: In Google Analytics 4 User Interface

    In the "Explore" -> "User Explorer" report in Google Analytics, you can view the IDs of individuals who visited your site, along with the name of the stream, the number of events and sessions, revenue, transactions, and conversions.

    This information enables you to perform detailed analytics and understand user interactions on your site effectively.

    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):

    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.

    #2: In GA4 export data to BigQuery

    In BigQuery, every event collected from Google Analytics 4 contains a field called user_pseudo_id. It’s basically the client ID.

    Uncover in-depth insights

    Step-By-Step Guide - How to Set up [GA4] to BigQuery Export

    Download now

    Bonus for readers

    Step-By-Step Guide - How to Set up [GA4] to BigQuery Export

    #3. Checking _ga cookie in developer mode

    To view a 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:

    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.

    #4. Getting clientid as a custom parameter

    To access the ClientID in other Google Analytics 4 reports, you must pass cid as a custom parameter. You can read about how to do that in this article below.

    Before proceeding to the description of how to pass Client ID to GA4, we would like to dwell on such a parameter as data 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 .

    Automate your digital marketing reporting

    Manage and analyze all your data in one place! Access fresh & reliable data with OWOX BI — an all-in-one reporting and analytics tool

    Start Free Trial
    Automate your digital marketing reporting

    How to Get Custom Google Analytics ClientID

    How do you transfer the Client ID to a custom Google Analytics option? When working with Google Analytics Universal, the most optimal way was 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 a lot) 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 Property settings and select the Custom Definitions section under Data Display:

    Then click Save:

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

    Now, you need to ensure that Client IDs are written to an additional parameter each time the user interacts with the site. We 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:

    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; 
    }

    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.

    To ensure Client ID is captured and sent correctly to GA4, activate Preview mode in Google Tag Manager (GTM). Review the debug panel, inspect your GA4 configuration tag, and confirm that "client_id" is set in the User Properties.

    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)

    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):

    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.

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

    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:

    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;
    }

    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:

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

    Using the Realtime report or Debug View (I recommend installing the extension to track your hits), you can check the implementation's correctness. You can see examples of how to check hits in Debug View or how to display Client ID in a report via the 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

    Effective Client ID management is essential for accurate tracking and analysis in Google Analytics 4 (GA4). Implementing best practices ensures reliable data collection and insightful user behavior metrics.

    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.

    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.

    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.

    Differences Between Client ID and User ID in Google Analytics 4

    In Google Analytics 4 (GA4), distinguishing between Client ID and User ID is essential for accurate user tracking. While Client ID identifies unique devices, User ID tracks individual users across devices. Understanding these differences helps optimize user insights and analytics strategies.

    Scope of Tracking

    Client ID: Tracks user interactions on a single device and browser. It does not provide a unified view if a user switches devices or browsers.

    User ID: Tracks user interactions across multiple devices and browsers, providing a comprehensive view of the user’s behavior and interactions regardless of how they access the site or app.

    Implementation

    Client ID: Automatically generated and implemented by GA4, requiring no additional setup beyond the basic GA4 configuration.

    User ID: Requires manual setup and implementation by the developer. The site or app must generate and assign a unique user ID to each logged-in user.

    Storage

    Client ID: Stored in a first-party cookie on the user's browser. This cookie persists across sessions on the same device and browser but does not transfer if the user switches devices or browsers.

    User ID: Stored on the server side, typically in the user database of the website or app. This allows consistent tracking across different devices and browsers, as the user ID is associated with the user’s account rather than their device.

    Data Accuracy

    Client ID: Offers accurate tracking within a single device and browser context. However, it can lead to fragmented data if users frequently switch devices or use multiple browsers, resulting in multiple client IDs for the same user.

    User ID: Provides higher data accuracy for tracking individual users across multiple devices and browsers. By linking interactions to a single user ID, it eliminates duplication and offers a more accurate and comprehensive view of user behavior and engagement.

    Use Cases

    Client ID: Useful for basic user tracking and analysis where cross-device tracking is not critical. It helps understand user behavior on individual devices and browsers.

    User ID: Ideal for more advanced tracking needs, particularly for websites and apps with a login system. It provides a holistic view of user interactions across all devices, enabling more accurate user segmentation and analysis.

    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 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 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 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
    • How to get a Client ID in Google Analytics 4?

      To get the client ID in Google Analytics 4, use the gtag.js library by accessing it through the browser console or your website's JavaScript. You can retrieve it by calling the get method on the gtag function with your GA4 Measurement ID, specifying 'client_id' to obtain the current user's client ID.

    • 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