User ID in Google Analytics Explained with Examples

What is Google Analytics User ID?

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

Google Analytics cannot generate unique IDs for you that can be used as User IDs. You also can not 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 log in and log out.

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

If your login ID contains PII then you may need to either remove that information from the Login IDs or completely rewrite the Login IDs before you send the Login IDs as User IDs to GA.

This is because the User ID usage policy requires that the User ID should not be a PII of a user. If you do not follow this usage policy, then Google may terminate your GA account.

In order to implement User ID, you would need to write code that can pull login IDs or other unique IDs from your authentication system and then place them in your Google Analytics tracking code.

That way the User IDs can be sent to the GA server along with the hit data. Consequently, any website which assigns 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 a login system

For example, Walt Disney World tracks offline customers through a special wrist band known as the ‘magic band’.

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

Then through measurement protocol and User ID feature, this offline customer data is 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 supermarket, 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.

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 as well with the help of measurement protocol, but the implementation is not going to be easy.

Once the User ID feature is implemented, GA combines and reports all the hits with the same User ID, regardless of which 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’, ‘dimension1’,userId);

Note: You can implement the User ID feature for both websites and mobile applications.

Difference between Google Analytics User ID and Client ID

Through User ID, you can create and assign your own unique 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 do not get confused. 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

Benefits of using Google Analytics User ID

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

#2 Through the 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. Unlike Client ID, the User ID can exist on multiple devices.

If a user is accessing your website from different devices/browsers then without User ID implementation, a unique user can be counted multiple times by GA.

For example,

If a user logs in to your website via smartphone and then later made a purchase via a company laptop, then in GA without User ID implementation, the number of unique users could 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 the 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 engage with your website very differently than those who are not logged in. Logged in users behave differently than non-logged in users and you should create separate marketing campaigns to retarget them, to cross-sell or upsell them.

#6 When you set up a User ID, you also get access to a special User ID view and cross-device reports in your Google Analytics account. User ID view is the Google Analytics view that displays only the sessions which contain User ID (the user is logged in) and their activity. This allows you to get a better understanding of user behaviour on the website and the activities they carry out.

User ID hits and sessions

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

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

2. Non-User ID hits – these are those GA hits for which a User ID has not been set.

Note(1): User ID hits are processed separately from non-User ID hits.

Note(2): If you are not using the User ID feature then the non-User ID hits are simply known as hits.

3. User ID session – It is the Google Analytics 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 provided the session unification setting (more about it later) has been turned ON.

4. 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 GA 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 GA session.

User ID Property

User ID property is that Google Analytics property in which user ID setting has been turned on:

ga user id user id turned on

User ID View

User ID view is the GA view which collects only the data related to user ID sessions:

ga user id User ID reports enabled

You know you are looking at the User id view when you see the setting ‘User ID Reports‘ enabled under ‘View Settings’.

You should consider adding the words ‘User ID’ somewhere in your view name for easy reference.

In the case of User ID views, GA calculates unique users by counting the number of unique User IDs assigned to the website visitors instead of counting the number of unique Client IDs assigned to the website visitors.

Non-User ID View

Non-User ID view is the GA view that collects data related to standard GA sessions.

It does not recognise 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 the website visitors.

You know you are looking at the non-User ID view when you see the setting ‘User ID Reports‘ disabled under ‘View Settings’:

ga user id User ID reports disabled

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

Revenue in a User ID view is based on users and not sessions.

When does a regular GA session turn into a User ID Session?

If you are using login IDs as User IDs then as soon as a user logs in, 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.

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

So, if the user doesn’t log in then the User ID is not assigned to him and no hits are associated with the User ID. Similarly, when the user logs 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

Through the User ID feature, you cannot track users and their activity from the very first time they visited your website and before they decided to sign up and log in. Thus, the User ID feature works well only for logged in users.

Now not all the users who visit your website login. So you may not be able to track a large portion of the users’ conversion journey. In order to overcome this limitation, you can keep your users logged in unless they explicitly logged out.

For example, Facebook keeps its users logged in all the time unless they explicitly logged out. In this way, Facebook is able to collect most of the cross-device behaviour data about its users.

Here are a few more User ID limitations:

  • Assigning User ID: Google Analytics on its own cannot generate or assign a User ID. This is generally done by the authentication system you use, Once the user signs up, or logs in, to your website, the User ID is passed to Google Analytics.
  • Product integration: You can connect Google Ads or Search Ads 360 with the User ID view, but you cannot integrate (connect) User ID view with Display & Video 360, Campaign Manager 360 and Google Ad Manager.
  • Feature limitations: A few Google Analytics features are not available in the User ID view:
    • Real-time reporting: Google Analytics does not show real-time data for User ID view. Data in the User ID view comes from the identified sessions. To protect individual user data (PII regulations) real-time view is not supported in User ID views.
    • Demographics and interest reports: The PII regulations also apply to demographics and interest reports which combine gender, age, and interest details of the users. Hence you won’t see any demographics and interest reports in the User ID view.
  • Blocking extensions – Adblockers and script blockers: If any of the website users are using the blocking extensions which block Google Analytics script and Google Tag Manager script and prohibit sending data to Google Analytics, this can affect the data that you collect including the User ID feature.

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 the User ID.

If a person visits your website without logging in, 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 user’s purchase journey.

However:

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

Associating Client ID with User ID works well only when a person is visiting and logging in to your website via the 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 the case of cyber cafes 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 login.

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 associates only one Client ID with the User ID.

How to turn off session unification

Session unification is a User ID setting that can be turned ON and OFF.

Session unification is turned ON by default and it should be kept turned on unless your company’s privacy policy issue prohibits you from collecting such data.

Since the 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 cannot be associated with the User ID then.

To turn off the session unification follow the steps below:

Step-1: Navigate to the ‘Admin’ section of your User ID view.

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

ga user id admin section

Step-3: Click on the ‘Edit’ link next to the step: ‘Set up the User ID’:

ga user id edit user id

Step-4: Scroll down a bit and then set the ‘Session Unification’ toggle switch to OFF:

ga user id session unification turned off

Note(1): Turning OFF the session unification setting is not recommended.

Note(2): Session unification is only available for User ID enabled properties.

How session unification works

Let’s take an example of how session unification works. The below image explains how session unification works when it is turned off.

ga user id Session Unification Turned off activity

Session 1: A user lands on your website and generates hits (events or pageviews). But the user is not signed in and hence no data will be assigned to any User ID

Session 2: A user lands on your website and generates hits (events or pageviews) and after this, the user signs in (specific User id is assigned) and generate more hits. In this complete session Hit 1 and Hit 2 will not be assigned with User ID if the session unification is turned “Off”. While Hit 3, Hit 4 and Hit 5 will be assigned to a User ID.

Session 3: In this session, the user is signed in for the complete session and hence all hits (events and page views) will be assigned to the User ID.

Session 4: In Session 4, the user is signed in when the session started, then he generates Hit 1 and Hit 2 and after that, he signs out. The user continues browsing and generates Hit 3, Hit 4, and Hit 5. In this session only Hit 1 and Hit 2 will be associated with the User ID (Since the user was signed in) but Hit 3, Hit 4, and Hit 5 will not be associated with User ID even they are recorded in the same session.

Session 5: In the complete session, the user is not signed in and hence all hits in this session will not be assigned with a User ID

Session 6: In this session, the user is signed in for the complete session and hence all hits (events and page views) will be assigned to the User ID.

Now let’s take another example of how session unification works when it is turned ON:

ga user id Session Unification Turned On activity

Session 1: A user lands on your website and generates hits (events or pageviews). But the user is not signed in and hence no data will be assigned to any User ID

Session 2: A user lands on your website and generates hits (events or pageviews) and after this, the user signs in (a specific User id is assigned) and generate more hits. In this complete session, all Hits will be assigned with User ID if the session unification is turned “On”.

Session 3: In this session, the user is signed in for the complete session and hence all hits (events and page views) will be assigned to the User ID.

Session 4: In session 4, the user is signed in when the session started, then the user generates Hit 1 and Hit 2 and after that, he signs out. The user continues browsing and generates Hit 3, Hit 4, and Hit 5. In this session only Hit 1 and Hit 2 will be associated with the User ID (Since the user was signed in) but Hit 3, Hit 4, and Hit 5 will not be associated with a User ID, even though they are recorded in the same session.

Session 5: In the complete session, the user is not signed in and hence all hits in this session will not be assigned with a User ID

Session 6: In this session, the user is signed in for the complete session and hence all hits (events and page views) will be assigned to the 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.

Setting up the User ID includes:

  1. Creating a new User ID view
  2. Generating unique IDs and then assigning them to website users.
  3. Sending IDs and all related engagement data to GA

How to create a new User ID view in Google Analytics

Follow the steps below to create a new User ID view in Google Analytics:

Step-1: Navigate to the Admin section of your GA Property and then click on the ‘User ID’ link under the ‘tracking info’ drop-down menu:

ga user id admin section

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.

ga user id user id policy

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

ga user id session unification turned on settings

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

ga user id create button

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

Step-5: Select your app (website or mobile app) for the User ID view:

ga user id website or mobile app

Step-6: Name your new reporting view and select your ‘reporting time zone’:

ga user id View Name and time zone

Tip: Include the word ‘User ID’ somewhere in the reporting view name. This way, you can easily differentiate this view from regular views.

Step-7: Toggle ‘On’ the ‘Show User ID Reports’ button and then click on the ‘Create View’ button.

ga user id create view

The process of creating the new User ID view is now complete.

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. This way, you can easily identify this reporting view later.

#2 You can create multiple User ID views on a User ID enabled property. The process is similar to creating multiple non-User ID views. Just turn the ‘User ID view’ toggle to ‘ON’.

#3 A User ID view collects and reports on only User ID sessions related data. So in order to get a complete picture of customer journeys, you need to use this view along with the non-User ID 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.

#5 Cross-device reports are available in the User ID views.

#6 Any existing non-User ID 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 Once you have enabled the User ID feature for a view, you cannot disable it.

How to generate, assign (to website users) and send User IDs to Google Analytics using Google Analytics tracking code (analytics.js)

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. You would need to first modify this tracking code.

Here:

{{USER_ID}} is a server variable (of type string) that 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. 

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 backend script then your final Google Analytics tracking code may look like the one below:

ga user id analytics code

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.

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

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

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

2. 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. In this way, 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, the 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

How to send User IDs to Google Analytics using Global Site Tag (gtag.js)

To set User ID using Global Site Tag (gtag.js), you can use below command with the tracking code.

gtag(‘config’, ‘UA-XXXX-YY’, {

  ‘user_id’: ‘USER_ID’

});

Your final code may look like below

          <!– Global site tag (gtag.js) – Google Analytics –>

<script async src=”https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID”></script>

<script>

           window.dataLayer = window.dataLayer || [];

           function gtag(){dataLayer.push(arguments);}

          gtag(‘js’, new Date());

          gtag(‘config’,’UA-XXXX-YY’);

          ‘user_id’: ‘USER_ID’

</script>

User ID coverage report

Through the User ID coverage report, you can determine the percentage of sessions that include activity from logged in users (provided your authentication system is login). Strangely you can’t access the User ID Coverage report through the User ID view.

This report is available in any non-User ID view which belongs to a GA property for which the User ID is enabled. You can find this report under Audience > Behavior > User ID Coverage:

ga user id user id covrage

This report shows the User ID status, which can be:

  • Unassigned – the number/percentage of sessions in which users weren’t assigned a User ID.
  • Assigned – the number/percentage of sessions in which users were assigned User ID.
ga user id assigned or unassigned

Note: Use the User ID Coverage report in conjunction with User ID view reports.

Cross-device reports in Google Analytics

Once you have set up User ID in your Google Analytics property, you can then access and use the cross-device reports via the User ID view.

ga user id device overlap

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. The sample report looks like below:

ga user id cross device report

You also get the total number of users using multiple devices:

ga user id cross device report numbers

To learn more about User ID cross-device reports, read this article: Google Analytics User ID Reports – Device Overlap, Device Paths, Acquisition Device

Related Articles

Frequently Asked Questions About User ID in Google Analytics

What is User ID in Google Analytics?

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

How do I find my Google Analytics User ID?

You can find your Google Analytics User IDs by navigating to the User Explorer report under the ‘Audience’ menu in your User ID view.

How do I enable Google Analytics User ID?

To enable the Google Analytics User ID, follow the steps below:
#1 Navigate to the Admin section of your GA Property and then click on the ‘User ID’ link under the ‘Tracking info’ drop-down menu.
#2 Read and agree to the User ID policy by toggling the blue switch to ‘ON’ and then click on the ‘Next Step’ button.
#3 Read and agree to the User ID policy by toggling the blue switch to ‘ON’ and then click on the ‘Next Step’ button.
#4 Click on the ‘Create’ button to create a new User ID view.
#5 Select your app (Website or Mobile App) for the User ID view.
#6 Name your new reporting view and select your ‘reporting time zone’.
#7 Click on the ‘Create View’ button.

What is the difference between User ID and Client ID?

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.

Is User ID the same as email address?

No. User ID is usually the login ID. However, the login ID should not contain personally identifiable information (PII) like name, email address, etc as it is against Google Analytics Terms of Service.

Register for the FREE TRAINING...

"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."



Here’s what we’re going to cover in this training…

#1 Why digital analytics is the key to online business success.

​#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.

#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.

#4 ​Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

#5 The number 1 reason why conversion optimization is not working for your business.

#6 How to advertise on any marketing platform for FREE with an unlimited budget.

​#7 How to learn and master digital analytics and conversion optimization in record time.



   

My best selling books on Digital Analytics and Conversion Optimization

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 BeyondSECOND EDITION OUT NOW!
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.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder, OptimizeSmart.com
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade
error: Alert: Content is protected !!