An Introduction to User ID Override in Universal Analytics

Universal Analytics has promised ‘user ID override’ for over a year now. It’s available in the USA, but us Brits won’t be seeing it anytime soon (legal reasons).

EDIT – 9th April 2014: Universal Analytics came out of Beta on 3rd April and it appears that User ID override is now supported in the UK. Details can be seen in the official documentation.

Even so, below is an explanation of what it is, and ways to overcome it’s limitations.

A quick intro to User ID override

If you don’t know what User ID override is, it’s a way of passing an ID you have assigned to someone into Google Analytics.

For example, a person creates an account on your e-commerce site. In the background your retail platform will generate a unique ID for that person and store it in a database somewhere. The person most likely never sees that number of knows they have been given it. But the system needs it to distinguish one John from all the other John’s (bad example but you get my meaning).

If you have Universal Analytics installed, Google has also created a unique ID for this person, and stored it in a cookie on their machine. Again, you won’t see this ID in Google Analytics, but it is there lurking in the background. It is how they can tie all the data about what someone is doing in a session or over multiple sessions together.

So the situation is now this:

  • Google Analytics ID (GAID): 1234
  • E-commerce Platform ID (EID): ABCD

The idea of user ID override is that you tell Google to use YOUR ID instead of their default ID, to make the situation look like this:

  • Google Analytics ID (GAID): ABCD
  • E-commerce Platform ID (EID): ABCD

Simple really.

Why is this useful?

Why would you want to send Google Analytics your customer ID rather than use theirs?

There are three main reasons.

  1. You can track people better across devices.
  2. You can tie you web analytics data to your other first party data (e.g. CRM data).
  3. You can track additional information about a person (such as offline behaviour) in Google Analytics.

Better tracking across devices

In a typical Universal Analytics set up, without User ID override, a person uses two devices (their mobile and desktop) would appear as three separate IDs:

  • Google Analytics ID (GAID for Mobile): 1234
  • Google Analytics ID (GAID for Desktop): 5678
  • E-commerce Platform ID (EID): ABCD

To Google Analytics, IDs 1234 and 5678 are two different individuals (two unique users). Your visit numbers, along with other important metrics are skewed. If the individual were to buy on their Desktop, the conversion rate would show as 50% (assuming each device had only been to the site once and there was no other traffic). In reality, the conversion rate should be 100%.

This also tends to distort campaign performance reports. Suppose that the person clicked on a PPC ad on their mobile and made their purchase decision. Then when they got home their switched to their desktop and entered your website’s domain directly and purchased.

Your PPC campaign would have a 0% conversion rate. You might decide to cull that campaign due to poor performance (which would be an incorrect decision because it indirectly led to the sale).

Now imagine that as soon as the person identified themselves on the mobile or desktop (when they create an account, sign in or click through from an email) we tell Google Analytics to override it’s ID with our E-commerce ID. We end up with:

  • Google Analytics ID (GAID for Mobile): ABCD
  • Google Analytics ID (GAID for Desktop): ABCD
  • E-commerce Platform ID (EID): ABCD

Google now understands that one person is using two devices, and the metrics in your account will be more accurate.

Merging web analytics to other data

You are a sports equipment retailer and Wimbledon tennis is about to start. Historically you know this leads to an increase in tennis rackets and trainers. To outperfom last year you decide to proactively market to your customer base via email.

But who should you email?

Firstly, there’s the obvious segment. Anyone in your CRM who has purchased any tennis related equipment 12 months ago (no point in trying to sell a tennis racket to someone who bought one last week). But this segment isn’t large enough.

So you decide to target anyone who has visited the tennis category on your website in the past 2 months but not purchased any tennis related gear.

You can build this segment quickly in Google Analytics.

But these are anonymous users. How do you link them back to the email addresses you have in your CRM database?

If you haven’t chosen to store your own User ID in Google Analytics you are stuck. It’s not possible.

But if you have, then the world is your oyster (kinda).

Provide you have Google Analytics Premium and have enabled Big Query integration, you will be able to query the data and produce a list of the relevant User IDs which you can then match up to email addresses in your CRM data.

The other option is to have stored your User ID in a custom dimension for all pageview and events you send to Universal Analytics (I recommend this). That way you can build a custom report within the GA interface to show you the list of User IDs to market to.

Either way, you need to have sent your User ID to Google Analytics in order to link on-site activity back to your CRM data for activation.

Tracking offline behaviour in Google Analytics

The final reason to send a User ID to Google Analytics is so that you can append your on-site behavioural data with offline data.

Suppose having researched tennis rackets on your website, the person goes to your physical stores and buys. At the EPOS the sales staff asks for their email address, which is associated with the transaction.

You now know that user ABCD bought a tennis racket offline. So why not send that data to Google Analytics (use the Measurement Protocol). And the only way Google Analytics can link that offline behaviour to the on-site behavioural data it has already got stored is via the User ID.

If you haven’t set the user ID then you can’t link the two sets of data.

How to implement in Universal Analytics

The User ID is set in the standard tracking tag that goes on all pages of your website.

[code] ga(‘create’, ‘UA-XXXX-Y’, { ‘userId’: ‘USER_ID’ });
ga(‘send’, ‘pageview’);

Simply replace USER_ID with a user ID generated by your site.

As this ID is normally stored in a database, you will have to get your web developers to output the ID into the JavaScript using server-side language your website is written in. In PHP, this would look something like:

[code] if (isset($userId)) {
$gacode = “ga(‘create’, ‘UA-XXXX-Y’, { ‘userId’: ‘%s’ });”;
echo sprintf($gacode, $userId);


  • User ID should be unique to every user.
  • User ID should not contain personal information. For example, don’t use email address.
  • Use a User ID that is common in all your IT systems across your business. If you have a User ID in your CRM system, use that. Don’t use a different one or you’ll have trouble merging online and offline data in the future.

See the official User ID documentation for further information.

Key points

  • If you are in the USA then you should be using User ID override.
  • If you are in the UK where the feature is not available, set the User ID in a custom dimension the User ID feature was released on 3rd April 2014 so you can now use it. I would still advise setting User ID in a custom dimension as well. It will help you create reports.
  • Even if you override the User ID, there is no way of seeing it within the Google Analytics interface (meaning you should also use a custom dimension if you are in the US).
  • Upgrading to Google Analytics Premium and integrating with Big Query will allow you to not only build segments but to activate them via multiple channels.
  • Remember to track important offline events and send them to Google using the Measurement Protocol, otherwise you are missing out on key parts of the customer journey and your data will be skewed.
Ed Brocklebank (aka Metric Mogul) is an analytics and digital marketing consultant. He helps business of all sizes become more data-driven through measurement, strategy and activation. He works as a Strategic Analytics Director at Jellyfish in London, as well as delivering training on behalf of Google and formerly General Assembly.