How to Configure User ID in Google Analytics 4

I love adding a bit of magic to the workflow. I think it makes it more exciting and special. This is why I believe that GA4 is a new galaxy, and we are brave explorers.

Every day is a new adventure, as we are exploring new features that are being rolled out. 

There is a common statement that GA4 is an upgrade of UA. Well, it is partially true, but at the same time, I would say that this is an entirely new tool with the new data model. It can be challenging but fun as well.

Master the basics with our FREE GA4 Course for Beginners

GA4 has changed drastically, and this is why it is fundamental to perceive it with an open mind. It is important to work with new features without constantly comparing GA4 to UA, as 1-to-1 migration would never be possible.

It might seem very daunting and frustrating because the sunset of UA is too hasty. 

🚨 Note: If you’re struggling with switching over to GA4, check out our handy GA4 migration guide, which is explained in 11 steps.

There are many things we have to learn from scratch, we will focus on one of the features in this post. Specifically, we will discuss how data is collected and focus on User ID in Google Analytics 4.

Here’s the outline of what we’ll cover:

  1. Data Collection in GA4
  2. GA4 Reporting Identity
  3. User ID Implementation with GTM
  4. Verifying Your Setup
  5. How to work with the User ID
  6. Some Important Tips

Data Collection in GA4

How are your users tracked in GA4? How do you collect data about your users in GA4?

The standard way of collecting data in UA is rather limited. 

For example, let’s say you have a user with multiple devices. A guy or girl wakes up in the morning checks his or her phone and visits your website. 

Then this person goes to work, opens a new tab, and continues browsing your page on the laptop. 

Later, this person goes back home and uses a tablet to continue exploring your website. 

Therefore, this is a single-user journey on your website, however, due to the cookie limitations, UA would display three different sessions. 

This would happen with the help of a client ID. It is a unique, randomly generated string that serves as an identifier and anonymously identifies a browser instance. 

In this way, Analytics can identify your users, as their client ID gets stored in the browser cookies, so that all their subsequent visits to your website can be associated with the same user. 

However, a client ID is limited, as it is basically related to your user’s device.

You might wonder what the solution could be in this case. This is where the beauty of GA4 comes in. One of the greatest steps forward with this tool is its cross-device tracking. 

So now it is possible to track your users across multiple devices with GA4.

GA4 Reporting Identity

In the Admin panel, there is a section called Reporting Identity. This is where you can choose how to collect the data about your users.

Specifically, GA4 offers four different methods to unify a single cross-device user journey:

  • User ID
  • Google signals
  • Device ID
  • Modeling
GA4 Reporting Identity Settings

We have three reporting identity options here. 

GA4 Reporting Identity Options

The first option is blended. It relies on the User ID if you have this feature. 

If no User ID is collected, then Analytics falls back on Google signals if this option is enabled. 

However, if neither User-ID nor Google-signals are available, then Analytics uses the Device ID. If this option is not available, GA4 would use modeling.

Reporting Identity Principle

The second option (observed) uses the user ID, and if it is unavailable, GA4 takes information from Google signals. If both are unavailable, GA4 uses the device ID.

The last option is device-based, using only the device ID, ignoring other collection methods.

Now you have an idea of how users are tracked in GA4, and we can focus on User ID in Google Analytics 4. What is it about, and is it the same as a Client ID? 

So, let’s say you have a website where users can log in, providing their credentials.

Login System

This is how the system knows that this is the same user when they browse your website. 

In this case, even if a user visits your website with multiple devices, GA4 can perceive that this is a single journey. 

However, it is essential to understand that this option is available for websites or applications where you have some identification method.

As discussed, if a User ID is not available as well as Google signals, a Device ID is used. This is the previously known Client ID in Universal Analytics or the so-called user pseudo ID. 

This method is exactly like the standard way of tracking users in Universal Analytics, as the system would recognize a device only in this case. 

Therefore, this is the least reliable and the least precise method due to the inability to identify a cross-device journey.

User ID Implementation with GTM

As the User ID is not available by default in GA4, it has to be implemented on your own. In this article, we will cover its implementation with the help of Google Tag Manager. 

When we preview our GTM container and log into our system, we can see a custom event called userLogin. It fires each time a user provides their credentials to access our platform.

userLogin Custom Event

If we extend the API Call, we can see the information about our user, specifically a user ID as well as a loyalty tier.

Information About a User

It is important to understand that this must be set up additionally. In our case, the data about users from our CRM system is pushed into the data layer. 

To be able to get this data, you might need to ask your developer to create a data layer for you, or you could also use a plugin if there is any available. This step depends entirely on your website specifics and must be addressed specifically.

The first thing you need to set up in GTM is a variable that would store the value of our user ID. You should go to your GTM account and click Variables → New. 

Creating a new variable

Now, we should click on Variable Configuration.

Variable Confuguration in GTM

We are working with the data layer, and this is why we should select a Data Layer Variable.

Selecting a Data Layer Variable

We should provide the same name as you have in your data layer. In our case, we already checked it in the preview mode and found that it is user_id.

Setting Up a Variable

Now our variable is set up and ready to be used. Let’s save it and open our GA4 Configuration Tag. Under Fields to Set, you should provide a field name user_id and select our variable as a value. 

GA4 Configuration Tag

This is the whole setup. It is not that complicated, right? 

However, there are some crucial aspects to keep in mind. 

As you can see, my custom event fires before the Analytics tag, as I want to have my user data available before Analytics is loaded. 

Therefore, you should make sure that your data layer is implemented correctly, as the order is crucial here.

Tag firing order

Another important thing: You should not create any value in the data layer for users who are not logged in. 

It might be tempting to create a default value like unknown, but it might break the implementation. Thus, you should not set up any value if a User ID is unavailable.

Verifying Your Setup

Here comes the most exciting part – testing. Let’s preview our GTM container again and also log into our system. 

userLogin Event test

Navigate to your GA4 property and click Configure → DebugView.

Navigating to DebugView in GA4

If you see the orange text here, you’ve set up everything correctly.

User ID in DebugView

If you click on any event after your login, you should see your user_id property under User Properties.

Checking User ID under User Properties

How to work with the User ID

Now comes the most important question: Where can I see my User ID after it has been implemented?

There is a dedicated exploration for that called User Exploration. You can find it by clicking Explore on the left side.

User Exploration in GA4

Here you can see the values of App Instance ID.

Note that it is the same name for both websites and applications. You can see this long number with a dot that is a user pseudo ID, and the User ID we configured. 

User Exploration

If you click on the User ID, you can have an overview of this user’s activity on your website.

User Activity Overview

What if we want to see this User ID in different custom reports? One of the options could be to set up a separate custom parameter for that. 

Is this a good solution? Well, this is a philosophical question, since you might face some cardinality issues in this case. 

According to Google documentation, you should avoid using a custom dimension to create user identifiers since this would be a high-cardinality dimension.

Another way to use this feature is to create a comparison in the reports section. In this way, you can make a quick analysis, comparing all users against logged-in users.

Building a comparison

To do that, you should provide a condition that Signed in with user ID equals true and then click Apply.

Comparison conditions

Some Important Tips

There are a few things you should keep in mind when it comes to User ID implementation.

1. (Extremely important!) You must not send any personally identifiable information with your User ID, such as the user’s name, surname, email, address, etc. You are fully responsible for complying with the Privacy Policy.

2. The User IDs you configure must not exceed 256 characters.

3. Data you collect will start getting associated with a user ID only AFTER your implementation. 

Summary

GA4 offers a powerful feature that can help you to dive deeper into the analysis. It is only available when you have some user identification method.

The User ID in Google Analytics 4 allows you to associate your own identifiers with individual users so that you can build a comprehensive picture of your user journey across devices.

In this way, you can achieve more accurate numbers in your reports, and get a holistic story about people’s engagement with your website.

If you want to ensure that your analytics setup is efficient enough, check out our handy GA4 audit guide.

Have you already implemented this feature in your GA4? Did you set up an additional parameter to use as a dimension in your various explorations? Please share your experience in the comment section.

JOIN US!

Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Richard M
Richard M
1 month ago

Why does my user count data in GA4 vary from UA when User ID is not configured. does this have anything to do with Event Measurement but how?

Dat Lam
Dat Lam
1 month ago

Hello, thanks so much for the post. I have a question: if now a user log in to my website (with user id = 1234) and next time that user comes back to my website with the status logged in already (he doesnt need to log in again so there is no event log in), can GA4 continue to track the data of that user id 1234 or not?

Dana
Dana
6 days ago

Is there any chance you can replicate this demo for all the wordpress users out there? WordPress uses visitorID and, theoretically, should work the same way but I tried checked it multiple times and it will not track. The visitorId is clearly listed in the data later, but just won’t track in GA4 whatsoever. We’re using the GTM4WP plugin and still no luck.

Blog Categories

Want to turn your skills into a profitable investment? Subscribe & Get our FREE Course

How to Sell GA4 FREE Course

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.