Track Conversions With Google Analytics' Client ID & User ID


Last updated: July 25, 2019

Google Analytics is an underutilized tool and there are a few basic things you can do to gain more insight into your conversions. Last year in March of 2016 Google made their new User Explorer available to the public. It’s a great tool but unfortunately, you can’t drill down into other dimensions with this tool yet. Also, you can’t combine this information with other dimensions or metrics like where the user came from.


google analytics client id user report


What the User Explorer essentially does is aggregate users based on the client id that google collects in the form of a cookie set in your visitor’s browser. Google uses this cookie internally but doesn’t make it accessible to Google Analytic’s users. The only way to access the client id is by exposing it and sending it to your Google Analytics property as a custom dimension.


google analytics client id user report list


Why You Need to Add Client ID Now

When you’re ready to start looking at where your conversions are coming from, you’ll want to connect the information related to where they came from and how they interacted with your site. Unfortunately, you wont have that data. And you’ll have to wait until you’ve collected enough data to make any kind of assessment on conversions.


google analytics client id in zoho crm

Data collected in a CRM with custom session data and outgoing link to Google Analytics User Explorer

Assuming that you are collecting your visitor’s client id when they convert, you can query as far back as you like on that user to visualize every step they took to convert. You can also view all of the channels that they navigated to before converting.

How to Add Client ID as a Custom Dimension

You can add the client ID as a custom diemsion in google analytics by navigating to the admin section of your account and selecting the web property you want to modify/


add custom dimension to google analytics


Select Custom Definitions / Custom Dimensions and click on the “New Custom Dimension” button.


add client id to google analytics


You want to add the name “Client ID” and set the scope to Session. You can add it as a Hit or User if you like but Session based granularity is appropriate since a session encompasses hits when a visitor interacts with your site and user based collection might miss some session interactions you’ll want to observe at a later time.


add session based client id to google analytics


Then you can set the custom dimesion value to your website according to the dimension id that google provides.


add custom dimension client id to website embed code


You’ll want to add the following code as an ammendment to the default embed code that Google Analytics provides. So if you have the default Universal Analytics snippet installed on your website, you’ll want to modify it as shown in the examples below. You can also see the documentation provided by google.

Universal Analytics Implementation of Client ID

Before

ga('create', 'UA-XXXXXXX-1', 'auto');
ga('send', 'pageview');

After

ga('create', 'UA-XXXXXXX-1', 'auto');
ga(function(tracker) {
  var clientId = tracker.get('clientId');
  ga('set', 'dimension1', clientId);
  ga('send', 'pageview');
});

You also have the option of sending the client id as a non-interaction event via Google Analytics like so:

ga('create', 'UA-XXXXXXX-1', 'auto');
ga(function(tracker) {
  var clientId = tracker.get('clientId');
  tracker.set({dimension1: clientId});
  tracker.send('event', {
    nonInteraction: true
  });
});

Gtag Implementation of Client ID

Before

gtag('config', 'UA-XXXXXXX-1');

After

gtag('config', 'UA-XXXXXXX-1', {
  'custom_map': {
    'dimension1': 'clientId'
  }
});

Google Tag Manager Implementation of Client ID

You have the option of either setting a field with the name customTask and adding the code to extract the client id in your Google Analytics Setting Variable or to send the client id as a non-interaction event on all Window Loaded Page Views.


add client id to google analytics


To set the customTask field, create a custom javascript variable and add the code as follows:

function() {
  return function(model) {
    model.set('dimension2', model.get('clientId'));
  }
}

To set as a non-interaction event, create a custom javascript variable like so:

function() {
  try {
    var trackers = ga.getAll();
    var i, len;
    for (i = 0, len = trackers.length; i < len; i += 1) {
      if (trackers[i].get('trackingId') === {{GA Property ID}}) {
        var clientId = trackers[i].get('clientId');
        return clientId;
      }
    }
  } catch(e) {
  	return '(not set)';
  }
}

Difference Between Client ID and User ID

Depending on whether you have an authenitcation system on your website, you may have the added option of tracking your users. The benefit of doing so in the context of attribution is that you can stitch cross device sessions together. By default Google Analytics separates “Users” based on the cookies that it sets in your visitor’s browsers (Our beloved Client ID). But in an age of multiple device usage, it leaves a big hole in proper attribution techniques.

If you have an optinon to also send User ID data to Google Analytics for tracking, it’s a must for in-depth attribution techniques.

Google Analytics has an option where you can set an id for Users in the the admin section under Property > Tracking Info > User-ID.


add client id to google analytics


What you get is an additional View where you can track the behavior of your logged-in users. Unfortunately, it doesn’t automatically stitch all of the activity of a particular browser with another browser when a user is logged in. You can see more in google’s documentation for user id here.

You will need to do this manually by not only setting the userID field in Google Analytics but also creating a custom dimension for User ID and sending that data alongside the standard configuration variable for User ID provided by Google Analytics so you can query that data at a later time.

What you end up with is the option of pulling User ID and Client ID from Google Analytics and tracking all of the sessions for a particular user. Where once you had a dark void of direct sessions, you can now extract additional session data from all of the devices that your users used to log in to your site.

Need Help Setting Up Your Custom Dimensions?

Sometimes it’s not always so simple to configure custom dimensions. Your developer may have set up your analytics in a custom way ot you might be using Google Tag Manager to manage all of your js snippets.

If you need help to install your custom dimesions. Talk to an expert today


Recent Blog Posts