Setting up Cross device tracking via User Id in Google Analytics

User id is simply a unique set of alphanumeric characters (like UD23ddd3432) assigned to a user so that he/she can be identified across devices/ browsers and over the course of multiple sessions.

If you want to measure across devices in GA then you need to create and assign you own uniques IDs to the users. You can do that by using the ‘user-id’ feature of GA.

Through ‘user-id’, you can create and assign your own ids to track unique users instead of using the client ids generated by the Google Analytics tracking coding.

A client id represents a unique device/browser. Whereas a user id represents a unique user that may interact with your website using multiple devices/browsers.

It is important that you understand the difference between ‘client id’ and ‘user id’ and don’t get confused later. They are not the same thing.

To learn more about the difference between ‘Client ID’ and ‘User ID’, read this article: Understanding the difference between Client ID and User ID

Once the user id feature is implemented, GA combine and report all the hits with same user id, regardless of the device, the hits come from. This makes cross device measurement possible in GA.

You can send user id to Google Analytics by creating a new custom dimension (with user scope):

ga(‘set’, ‘dimension2’,userId);

Note: You can implement the user user id feature for both websites and mobile applications.

 

Benefits of using the User ID

#1 The usage of user-id feature makes cross device measurement possible in GA. This is the biggest benefit of using the user id.

#2 Through user id feature, GA can more accurately identify the number of unique users and their engagement activities (click on links, page navigation, screen navigation etc) across multiple devices and/or sessions, as unlike client ID, the user ID can exist on multiple devices.

Without user id implementation, a unique user can be counted multiple times by GA if the user is accessing your website from different devices/browsers each time.

For example,

if a user login to your website via smartphone and then later made a purchase via company’s laptop, then in GA without user id implementation, the number of unique users would be counted as two. But after user id implementation, the number of unique users would be counted as one.

#3 You can attribute user engagement spread across multiple devices and sessions to a single user in your GA reports. Thus user id helps in fixing attribution modelling issues.

#4 Through user id feature, you can get a holistic view of the users’ purchase journey.

#5 User id is a great feature to segment and analyze the logged-in users, as these users generally engaged with your website very differently than those who are not logged in.

 

User ID Hits and Sessions

In order to understand how user ID works, you need to get familiar with the user ID related terminologies which are frequently used:

User ID hits – these are those GA hits (pageviews, screenviews, events, transactions etc) for which a user ID has been set.

Non-User ID hits – these are those GA hits (pageviews, screenviews, events, transactions etc) for which a user ID has not been set.

User ID hits are processed separately from non-user ID hits.

Note: If you are not using the user ID feature then the non-user ID hits are simply known as hits.

User ID session – It is the session in which a user ID is assigned to a user. User ID session is a collection of user ID hits but may also include non-user ID hits if the session unification setting (more about it later) has been turned ON.

Non-user ID session – it is a collection of non-user ID hits. If you are not using the user ID feature then the non-user ID sessions are simply known as sessions.

Note: A standard session (non-user ID session) turns into a user ID session the moment a user ID is assigned to a user. This can happen when a user login in the middle of a standard web session.

 

User ID Views and Property

User ID property – it is that GA property in which user ID setting has been turned on.

User ID view – it is the GA view which collects only the data related to user ID sessions. In the case of user ID views, GA calculates unique users by counting the number of unique users IDs assigned instead of counting the number of unique clients IDs assigned to users.

Non-user ID view – it is the view which collects data related to standard sessions. It does not recognize user ID hits. In the case of non-user ID views (regular views), GA calculates unique users by counting the number of unique client IDs assigned to users.

If you are not using the user ID feature then the non-user ID views are simply known as views.

The number of unique users reported by non-user ID views are usually more than the number of unique users reported by user ID views. This is because user ID views only report on the users which triggered the user ID sessions.

Note: Revenue in a user ID view is based on users and not sessions.

 

If you are using login IDs as user IDs then as soon as a user login, a unique ID (login ID) is assigned to the user which is then sent as a user ID to GA.

So once the user login, a regular GA session turns into a user ID session and the user ID is set for all subsequent hits.

In Google analytics, by default collected hits can be associated with a user ID only in a user ID session and that too before and during user’s login but not after the user has logout.

So if the user doesn’t login then the user ID is not assigned to him and no hits are associated with the user ID. Similarly, when the user logged out, the user ID is no longer assigned to him and the new collected hits are not associated with the user ID.

 

Limitations of User ID

User id feature works well only for logged in users. Not all the users log in first before they visit your website. Users do not decide to signup and login until they are ready to make a purchase.

Through user id feature you can not track users and their activity from the very first time they visited your website and before they decided to sign up and login. Thus you would still not be able to track a large portion of the users’ conversion journey.

 

Overcoming the limitations of User ID through Session Stitching

You can associate client ids with user ids to track users’ activities before they decided to sign-up and login through a method known as Session unification (or session stitching).

Thus to an extent you can overcome the limitations of user id.

If a person visit your website without logging then a unique client ID is assigned to him. Now if the same person later logged in, then a unique user id is assigned to him.

By associating the client ID with the user ID, you can determine what the logged in person did on your website before he signed up and/or logged in.

In this way, you can get a better picture of the person’s purchase journey.

However,

‘Session Unification’ won’t solve all of your attribution issues.

Associating client id with user id works well only when a person is visiting and logging in to your website via same device and browser and he is the only person using that device and browser.

If multiple users are using the same device and browser (quite common in case of cyber café or office computers) then there is no guarantee that the person who browsed your website without logging in, is the same person who later visited your website after log in.

Similarly, a person can visit your website via multiple devices and browsers before logging in. In that case he would be assigned multiple client IDs but only one user ID. Session unification will associate only one client ID with the user ID.

 

How to Turn off Session Unification?

Session unification is a user ID setting which can be turned ON and OFF. Session unification is turned ON by default.

Since session unification setting is turned ON by default, all of the hits collected before the login and during the login, in a user id session are automatically associated with the user id.

If the session unification setting is turned off then only the hits collected during the login, in a user id session can be associated with user id.

The hits collected before the login in the user id session can’t be associated with the user id then.

To turn off the session unification follow the steps below:

Step-1: Go to the ‘Admin’ section of the user id view.

Step-2: Click on the ‘user-id’ link under ‘Tracking Info’ drop down menu:

user-id

Step-3: Click on the ‘Edit’ link next to the step: ‘Set up the user id’.

edit set up the user id

Step-4: Set the ‘session unification’ toggle switch to OFF:session-unification-on

Note: Turning OFF session unification setting is not recommended. Session unification is only available for User ID enabled properties.

 

Requirement for setting up the user id

GA cannot generate unique IDs for you that can be used as user ids. In other words you can’t use client ids as user ids. It doesn’t work that way.

In order to implement the user id feature, you need to generate your own unique ids and assign IDs to new and returning users through your user authentication system.

This user authentication system is usually your website login, the system through which users can login and logout.

The unique ID that you use to identify a logged-in user (also known as login id) on your website can be sent as user ID to your GA account provided the login id does not contain personally identifiable information like name, email address etc.

If your login id contains personally identifiable information then you may need to either remove that information from the ids or completely rewrite the ids before you send the ids as user ids to GA.

Note: According to user id usage policy, the user id should not be a personally identifiable id like name or email address of a user. If you don’t follow this usage policy, Google may terminate your GA account.

In order to implement user id, you need to write a code which can pull login ids or other unique ids from your authentication system and then place them in your Google Analytics tracking code so that they can be sent to the GA server along with the hit data.

Consequently,

Any website which assign login ids to its users is a good candidate for implementing the user id feature.

You can implement user id features in many ways other than through login system.

For example:

‘Walt Disney World’ track offline customers through a special wrist band known as ‘Magic band’.

This colorful, harmless, innocent looking band which is used to enter the parks, check in Disney hotels, buy food and merchandise is actually a tracking device through which company collects browsing and buying behavior of their offline customers.

Then through measurement protocol and user id feature this offline customers data can be connected with the online data to get a holistic view of the customers’ journey.

Similarly, if someone uses some type of loyalty card for making a purchase in a super market, then that loyalty card can be scanned to assign a unique id to the user which can later be sent to GA via measurement protocol and user id.

 

Setting up the User ID

The user id feature is available only in universal analytics and is set at the property level. The implementation of user id depends upon your environment/platform.

Throughout this article, I have used login as the user authentication system. Other users’ authentication systems widely used are:

  1. Biometric identification (like retinal scan, fingerprint scan, iris recognition, voice recognition, signatures etc)
  2. Punching cards to record attendance (like attendance of employees)
  3. Wrist bands (like the one used by Disney)
  4. Retail loyalty cards (used by many supermarket chains)
  5. Online and offline Coupons

User ids can be set for all of these authentication systems with the help of measurement protocol but the implementation is not going to be easy.

Setting up the user-id includes:

  1. Generating unique ids
  2. Assigning ids to users
  3. Sending ids and all related engagement data to GA

In order to set up user ID, you first need to create a user ID view. Follow the steps below:

Step-1: Go to the Admin section of your GA account and then click on the ‘user id’ link under ‘tracking info’ drop down menu:

tracking info

Step-2: Read and agree to the user id policy by toggling the blue switch to ‘ON’ and then click on the ‘Next Step’ button.

review the user id policy

Step-3: Keep the ‘Session Unification’ button setting intact (i.e. switched ON) and click on the ‘Next Step’ button.

Step-4: Click on the ‘Create’ button to create new user ID view:

create

Note: The user ID data will appear only in the user ID view.

Step-5: Select your app (desktop/website app or mobile app) for the User ID view. Enter view name and select your ‘reporting time zone’:

user-id-view

Note: Include the word ‘user id’ somewhere in the reporting view name. In this way you can easily differentiate this view from regular views.

 

Step-6: Add the following line of code to your Google Analytics tracking code, on each web page of your website before any hit data is sent:

ga(‘set’, ‘userID’, {{USER_ID}});

So your Google Analytics tracking code may look something like the one below:

<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’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-1234567-34’, ‘auto’);

ga(‘set’, ‘userID’, {{USER_ID}}); 

ga(‘send’, ‘pageview’);

</script>

Note: Do not copy paste this code on your website. It won’t work. Use and modify your own tracking code.

Here {{USER_ID}} is a server variable (of type string) which pulls the unique ID generated by your authentication system.

You or your developer needs to write a code through which login ids can be pulled from your authentication system and sent as user ids to GA. So your final google analytics tracking code after user id implementation is also going to include some server side script.

For example if you use PHP as the back end script then your final Google Analytics tracking code may look like the one below:

ga tracking code for user id

Step-7: Ask your developer to write a code through which login IDs can be pulled from your authentication system and sent as user IDs to Google Analytics.

So your final google analytics tracking code after user ID implementation is also going to include some server side script.

There are two points, you need to keep in mind before setting up the user id:

#1 The user ID must be set after the tracking object has been created

#2 The user ID must be set before you send any hit data to Google Analytics

 

The user ID must be set after the tracking object has been created

The user ID must be set after the tracking object has been created, otherwise the user ID will not be associated with your web property and won’t work.

So following user ID set up will not work:

ga(‘set’, ‘userId’, {{USER_ID}}); // user id is set before the tracking object

ga(‘create’, ‘UA-1234567-34’, ‘auto’); // create a tracking object

ga(‘send’, ‘pageview’);

The correct user id set up would be:

ga(‘create’, ‘UA-1234567-34’, ‘auto’); // create a tracking object

ga(‘set’, ‘userId’, {{USER_ID}}); // user id is set after the tracking object

ga(‘send’, ‘pageview’);

Note: The user ID must be set on all the pages of your website otherwise you may not get accurate user data.

 

The user ID must be set before you send any hit data to Google Analytics

The user ID must be set before you send any hit data to GA, so that the user ID is set for all subsequent hits that occur on a page.

So following user ID set up is not recommended:

ga(‘create’, ‘UA-123456-34’, ‘auto’);

ga(‘send’, ‘pageview’);

ga(‘set’, ‘userId’, {{USER_ID}}); // here user ID is set after the pageview hit

The correct set up would look like the one below:

ga(‘create’, ‘UA-1234567-34’, ‘auto’);

ga(‘set’, ‘userId’, {{USER_ID}}); // here user ID is set before the pageview hit

ga(‘send’, ‘pageview’);

Similarly, following user ID set up is not recommended:

ga(‘create’, ‘UA-1234567-34’, ‘auto’);

setTimeout(“ga(‘send’,’event’,’Profitable Engagement’,’time on page more than 3 minutes’)”,180000);

ga(‘set’, ‘userId’, {{USER_ID}}); // here user ID is set after the event hit

 

Important points about the User ID View

#1 Make sure that, whenever you create a new user ID view, you include the words ‘User ID’ somewhere in your view name, in this way you can easily identify this view later.

#2 You can create multiple user ID views on a user ID enabled property, in the same way you create a standard view.

#3 A user ID view collect and report on only user ID sessions related data. So in order to get a complete picture of customers’ journey, you need to use this view along with the standard views.

#4 You will see data in your user ID view reports only after you have successfully implemented the user ID feature. Otherwise your user ID view reports will remain empty. You won’t see any data in them, not even in the real time reports, without first actually implementing (and not just enabling) the user ID.

#5 Cross device reports are available only in user ID views.

#6 Any existing standard view cannot be converted to a user ID view and vice versa. Therefore to collect user ID data, you have to create a new user ID view.

#7 User ID view collects data only after the user ID feature has been implemented. It can’t collect data retroactively.

#8 A user ID view, reports only on the data collected in the last 90 days.

#9 Once you have enabled the User ID feature, for a view, you cannot disable it.

#10 You can create multiple user id views on a user id enabled property in the same way you create a standard view. Just turn the ‘user id view’ toggle to ‘ON’.

 

Cross device reports in Google Analytics

Once you have setup User ID in your Google Analytics property, you can then access cross device reports via the User ID view.

Through cross device reports you can get a better understanding of how users engage and convert on your website across different devices and over the course of multiple sessions.

To learn more about cross device reports, read this article: Cross Device Reports in Google Analytics

Announcement about my new books

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and Beyond
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Himanshu Sharma

Certified web analyst and founder of OptimizeSmart.com

My name is Himanshu Sharma and I help businesses find and fix their Google Analytics and conversion issues. If you have any questions or comments please contact me.

  • Over eleven years' experience in SEO, PPC and web analytics
  • Google Analytics certified
  • Google AdWords certified
  • Nominated for Digital Analytics Association Award for Excellence
  • Bachelors degree in Internet Science
  • Founder of OptimizeSmart.com and EventEducation.com

I am also the author of three books:

error: Content is protected !!