Analysts rely heavily on Google Analytics to make data-driven decisions, which are contingent on data accuracy. Despite the usefulness of GA’s default reports, there are many caveats to keep in mind when analyzing GA data—especially for larger sites. For example, sampled data in GA reports provide results based on a representative sample of traffic for the date range selected. When you analyze data more granularly with a secondary dimension in a segmented report (by device type in an Organic Traffic report), data is limited further to results for a percentage of that percentage.
In other words, the closer you get to individual user data, the more sampled your data becomes.
GA is great for holistic representations of your audience but not necessarily for detailed insights on individual user behavior on your site. Despite the availability of the User Explorer*, Cross Device,** and Lifetime Value reports in the basic GA view, even the count of users is inaccurately reported in default reports. Enabling User ID tracking allows you to track users outside of Google’s limitations—allowing for more accurate user metrics, the ability to analyze logged-in vs. logged-out user behavior, and access to more reliable cross-device and lifetime value reports.
This post will explain how data collection works between User ID tracking and your default GA reports, introduce the benefits of tracking user engagement, and provide step-by-step instructions to setting up User ID tracking in Google Tag Manager.
*GA offers the User Explorer report in default reports, which defines individual users by Client IDs.
**At the time of this posting date, cross-device reports are offered in beta in default GA reports for users who are logged into their Google accounts with Ad Personalization enabled.
Why use User ID tracking?
GA already captures IDs for every user that visits your site, which are called Client IDs. However, Client IDs are specific to browser profiles and device types, unlike User IDs. In the default GA view, the same user who enters your site through two different Chrome profiles on the same desktop and through Safari on their phone counts as three separate users.
User ID tracking is set up by creating a new view within GA that collects data through a custom data layer. This data layer is a one-line script that directs GA to stitch together all sessions that occur among different browsers and devices for the same user under the same ID.
Benefits of User ID Tracking
There are three main benefits to User ID tracking:
- More accurate user count. The user view allows GA to consolidate users who were previously identified as separate users from multiple entry points and profiles.
- Data segmented by logins. Registered users may behave wildly differently than anonymous or guest users. User ID tracking allows you to compare the behavior of logged-in to logged-out users, providing more reliable metrics for both groups.
- Additional reports in GA. User ID tracking creates an entirely new view that collects only unique user data. Some granular reports in this view aren’t available in regular GA views, and even those that are aren’t based off accurate user metrics. Some additional reports available through enabling User ID tracking include some Cross Device reports and User Coverage report.
Sites that could benefit from LifeTime Value, logged-in user behavior, and cross-device behavior data should implement User ID tracking through Google Tag Manager.
User ID Tracking Elements
To set up User ID tracking, a site must have Universal Analytics and Google Tag Manager installed, and an authentication system. In most cases, the authentication system is login credentials for returning customers.
Every page should have the following two codes, in this order:
- dataLayer script: This will populate with the User ID for your GTM container to grab. The dataLayer script will look like this in the page source when populated: userID': '12483'}]; Work with a developer to have the number in the script above populate with a unique User ID whenever a user logs in to the site. Usually, a unique number can be pulled from login credentials.
- GTM container: Placed after the dataLayer script.
- Universal Analytics tag and variable: The Universal Analytics tag and variable have to be fired through your GTM container for this guide.
How to Set up User ID Tracking with Google Tag Manager
Using GTM is the easiest way to set up User ID tracking. User IDs can be captured through either a cookie or dataLayer variable in GTM. This guide focuses solely on the dataLayer method because it doesn’t require pre-established cookies.
After ensuring the dataLayer script and GTM container exist on every page of the site, create the dataLayer variable and modify your Universal Analytics tag in your GTM container.
First, create a new dataLayer variable and configure it to collect data from the dataLayer script by assigning the name “userID” (or whatever name was set in your dataLayer, highlighted above).
Once you have created a dataLayer variable, enable User ID tracking in your Google Analytics account:
- Navigate to Admin in the Google Analytics property for which you’d like to set up User ID tracking
- Navigate to User-ID tracking through Admin > Property > Tracking Info > User-ID
- Agree to the User-ID Policy by switching the toggle to ON
- Leave Session Unification ON: Although not mandatory, Session Unification allows you to collect as much data as possible. Hits collected in a session before a user logs in are assigned to that user’s Unique ID after the subsequent login.
- Create your new User-ID view
- Name your view, something with “User ID” in the name
- Enable User-ID reports by turning the toggle to ON under “Show User-ID Reports”
Now you can create the Universal Analytics variable and pageview tag. If you already have the Universal Analytics variable and pageview tag created, simply modify your variable to the configurations outlined below. Your Universal Analytics pageview tag has to be fired through your GTM container and not hard-coded on the page for this guide.
Open your Universal Analytics variable in GTM and set the custom field to send User ID data to your User ID view. Do this by opening up the “More Settings” drop-down menu and set the custom field as “userid” with the data layer variable just created as the value.
This next step is optional but will enable you to compare datasets between logged-in users and guest users in the same reporting view. Set a custom secondary dimension (using our Custom Dimensions in GTM guide) which will show up in regular reporting views, as seen below:
If you added User ID as a custom dimension in your Universal Analytics variable, you have to configure the custom dimension in Google Analytics. Under “Custom Dimensions” in Admin > Custom Definitions > Custom Dimensions, create a new custom dimension. Set the dimension’s name as the name set in your “Field Name” and set the scope as User.
Once you’ve taken these steps, you should have your new User ID view with individual user data and a custom secondary dimension in your default reporting views under the same property. Data may take a few hours to trickle into the new User ID view; you’ll need to collect data for quite a while before having actionable insights for device engagement strategies or customer lifetime value. This is a tactic for long-run optimization strategies, and it’s well worth the time and effort required for setup.