What is Client ID in Google Analytics: detailed setup guide

In this article, you’ll learn why you need a Client ID in Google Analytics and how it can benefit your business. We’ll analyze in detail how to make the Client ID parameter available in Google Analytics reports and why you should transfer it to your CRM system.

Table of contents

What is the Client ID in Google Analytics?

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

However, what in Google Analytics reports are called users would be worth calling browsers. Because 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.

Why do you need a Client ID?

The cid parameter 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 site at different times. With the Client ID, you can merge data from Google Analytics and CRM systems and set up end-to-end analytics to understand how your marketing efforts affect real sales online and offline.

The OWOX team will help you correctly set up the collection of Client ID and other parameters and indicators that are important for your business. The development of an individual metrics system will be useful for any company that wants to track user actions on the site and use analytics to make timely decisions. To learn more about how OWOX can help your business, book a free demo.

How does the Client ID work?

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.

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 generates a unique numeric Client ID for each browser–device pair. When a user visits a site, a Google Analytics tracking code sends this ID along with session data – page address, referral source, language, etc. – to Google Analytics.

The Client ID cookie exists for two years. That is, if you go to the same site from the same browser within two years, Google Analytics 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

To view your Google Analytics 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

In which Google Analytics report can you view Client ID? In the Audience –> Statistics on users report you can see the identifiers of people who have visited your site as well as the number of sessions, bounce rate, transactions, income, and CR for each user.

Audience –> Statistics on users report

By the way, if you have a lot of users and sessions, Google Analytics will turn on sampling and statistics in your reports will be distorted. To avoid this, you can collect raw data using OWOX BI.

Let’s return to the Statistics on users 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, the cid is available only in this Google Analytics report. You can add segments to it, but this report doesn’t help if you need to group Client ID with other parameters, such as traffic sources and channels, devices, referral URLs, etc. To access the Client ID in other Google Analytics reports, you must pass cid as a user parameter. We’ll tell you how to do it.

How to get Google Analytics Client ID

How to transfer Client ID to a custom Google Analytics option? There are several ways to transfer cid parameters to Google Analytics. We’ll talk about the most modern and convenient – using the customTask method. You can add customTask to the tracking code either directly or via Google Tag Manager. Let’s consider both options in detail.

Step 1. Create a custom parameter in Google Analytics

Open the Google Analytics admin area. Go to the resource settings, and in the Custom definitions section, select Special parameters:

Special parameters in Google Analytics

Click the + Special Parameter button:

Enter the name of the parameter, indicate that it should be available at the user level, and click Create:

Custom Settings in Google Analytics

A code will appear on the next screen. Click Finish:

As a result, you’ll have a new Client ID parameter in your admin panel. Pay attention to its index and remember that you’ll need it when you create a customTask:

Now you need to make sure that each time the user interacts with the site, Client ID’s written to an additional parameter. We show two configuration options: via Google Analytics code and Google Tag Manager.

Step 2. Add customTask

Via Google Analytics code

Open the developer console, find the Google Analytics code, and insert the following script between the create and send actions:

    
ga('set', 'customTask', function(tracker) {
   tracker.set('dimension1', tracker.get('clientId'));
});
    

Here is what it will look like in the end:

    
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto');
ga('set', 'customTask', function(tracker) {
   tracker.set('dimension1', tracker.get('clientId'));
});
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
    

With this action, you set the task for the Google Analytics counter to transfer the Client ID value to a custom parameter. Don’t forget to replace the number in dimension1 with the index of your parameter in Google Analytics. In our example, it’s 2.

After that, you can check if the identifier is correctly transmitted. Open your website in Chrome, press F12, go to the Network tab, refresh the page, and in the Filter field, write a collect to see which queries go to Google Analytics:

We find cuk cid in the query parameters and see that cd1 has appeared – that is, the second arbitrary parameter with the same value as that of cid. So everything is working correctly. 

Via Google Tag Manager

Now let's figure out how to do the same through Google Tag Manager. There are several options, consider one of them.

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

Variables in Google Tag Manager

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

Now you need to add the created Client ID variable to a GA Settings variable in the section in Custom Dimensions and publish the container. We’ve described how to check whether everything works above.

You can also see if the Client ID parameter is passed in any Google Analytics report. For example, you can do this by opening Traffic Sources –> All Traffic –> Source / Channel, adding the second Client ID parameter, and seeing user IDs:

Google Analytics Source/Channel report

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.

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

For this task, Google Analytics has a User ID that helps to link all actions of a user 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.

Our clients
grow 22% faster

Grow faster by measuring what works best in your marketing

Analyze your marketing efficiency, find the growth areas, increase ROI

Get demo