I often come across requests to prepare data that would include the number of Unique Users visiting a given site. In today's reality, however, this is more difficult than it might seem. In this article, I explain what exactly causes this and share proven ways to get around these difficulties.
The number of unique users is always an estimate. This is because recognizing them is very difficult. This is influenced by several factors:
Yes and no. Unfortunately, we have to accept most of the factors I have listed that negatively affect the completeness and correctness of user data.
When it comes to data loss, server-side tagging can be a partial solution , but it won’t solve all the problems either. Another possible option is to use data loss modeling from users who have declined to be tracked . However, this method will only work on high-traffic sites that have properly implemented Consent Mode .
There is also an easy and inexpensive way to recognize users more effectively. For this purpose, it is worth implementing a user ID on the website .
User ID is a unique identifier, usually a string of numbers, that is assigned to a logged-in user. User ID allows you to track user activity without revealing their identity. Their data remains anonymous under the law, because the user ID itself is not considered personal data until it is linked to data that uniquely identifies the user.
In Google Analytics, both user ID and client ID are used to track users, but they differ in how they work and in their scope of application.
Client ID is something completely different than intuition suggests. It is a unique identifier automatically generated by Google Analytics for each device/browser that visits your website. Client IDs are stored in the browser. One real user can have several Google Analytics cookies, and therefore several client IDs.
Mobile apps use app instance identifiers, not cookies. An app instance identifier is a unique identifier assigned to an installed app. Implementing user IDs in apps is especially important for organizations that want to measure (logged in) user behavior across platforms, such as between an app and a website.
When you configure GA, you have the option to choose your reporting identities . They are based on identifiers (known as identity spaces) such as:
In addition, we have several levels of reporting identity available :
Do you think the best choice would be to use as many available identifiers as possible? Not necessarily.
In some cases, data modeling in Google Analytics can be flawed, so if you care more about precision than identifying broad trends, you may want to choose a lower reporting identity level. It's worth comparing data across identity levels to make sure the modeling isn't introducing significant distortions into your reports.
You can use the dimension named "Logged in with user ID" and check if it accepts the values "yes". You can use this dimension in both standard reports (as a dimension, filter and comparison) and in Explore reports.
The most popular method of implementing a user ID is to use Google Tag Manager (GTM) . If Google Analytics is implemented in a different way, e.g. directly in the page code, it is best to ask your developer to add the user ID according to Google's instructions.
The most secure and optimal option is to use a user identifier that is placed in the data layer .
If you are not sure if there is a user ID in the data layer, you can look for it in GTM using the preview mode. Make sure you are logged in, because only then will the user ID have a value. In the data layer, the user ID can have different names, but they are most often similar to "user_id" or "userId".
The most secure and optimal option is to use a user identifier that is placed in the data layer .
If there is no user ID in your data layer, ask your developer to implement it.
The code could look something like this. It should be sent on every pageview to make the data even more accurate on login events.
window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'userId' : '123456789' // tu przekazywany jest identyfikator użytkownika })
window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'userId' : '123456789' // tu przekazywany jest identyfikator użytkownika })
window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'userId' : '123456789' // tu przekazywany jest identyfikator użytkownika })
In addition, the code should be called on every pageview BEFORE the Google Tag Manager code. This is important because it will give us access to the user_id variable value during the container loaded event, which is the most popular rule for tags called "All pages".
If you want to add user_id also in login event, then event should look like this and be called when user logs in:
window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event' : 'login', 'userId' : '123456789' // tu przekazywany jest identyfikator użytkownika })
window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event' : 'login', 'userId' : '123456789' // tu przekazywany jest identyfikator użytkownika })
window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event' : 'login', 'userId' : '123456789' // tu przekazywany jest identyfikator użytkownika })
If you use any of the popular e-commerce platforms, the user ID may be part of the data layer generated by GTM plugins.
If you have identified the identifier in the data layer, the first step is to create a data layer variable . In our case, the variable should be constructed like this:
The most secure and optimal option is to use a user identifier that is placed in the data layer .
In the last step, go to edit the Google tag . Add a configuration parameter called “user_id” and the value of the variable you created a moment ago.
Tracking user IDs in a mobile app requires setup in Firebase using the SDK (Software Development Kit) available for Android and iOS. Click here for instructions.
The most secure and optimal option is to use a user identifier that is placed in the data layer .
The best way to test the new solution is to use DebugView, which is located in the Administration tab in GA4. Here's how:
If you prefer to have your company's data analyzed by professionals, contact us. We perform analytical activities for online stores, service companies, publishing houses, NGOs and many other businesses. We provide all our clients with comprehensive reports in a clear visual form. Here you will find more information about the scope of our services.