How to set up User ID

A user who visits your website from desktop and mobile might be signed in on desktop, but not signed in from their mobile device. If you want to be able to track them across devices for a more accurate user count in your reports, you can use Google Analytics to collect User IDs.

Remember that Google Analytics sets an anonymous identifier that’s stored in a browser cookie to recognize unique users. The User ID feature lets you override this default behavior letting you instead associate your own anonymous identifier from a CRM system or customer database. 

User IDs allow you to connect an ID from your database to your website when your users interact with that content. You could pull a User-ID from your database, pass it through web servers to your website, and then the Google Analytics tracking code can include that ID with its data hits. 

To implement the User ID feature, you must be able to generate your own unique IDs using JavaScript code, consistently assign those IDs to users, and include these IDs wherever you send hit data to Google Analytics.

To set up the User ID feature in Google Analytics, go to the Admin section, then select an account and a property. Under Property, click Tracking Info, then click User ID. 

First you’ll need to review the User ID policy. This is pretty important, since you’ll want to be sure you respect your users’ privacy and honor the Google Analytics’ “Terms of Use.”

Then you’ll need to set up the User ID. Analytics provides you with a line of code to add to your own tracking code and customize it to collect the User IDs you’re sending over. Once you’ve set up User IDs and modified your tracking code, the ID value you supplied will be included in Analytics with each hit.

However, there may be cases when a user is not logged in to your website or app, and Google Analytics will be unable to collect the User ID. In that case, Analytics will go back to its default behavior and generate its own User ID, and will not be used to measure across devices.

To avoid a situation where you have multiple User IDs associated with a single user, you can enable “session unification.” This associates the User ID with hits collected in the same session before the User ID was assigned. With session unification, Google Analytics can associate some hits that were received prior to setting the User ID. Note that Analytics will only associate hits collected in the same session and it must be in the first session where the User ID is set.

Note that to analyze User ID data, you’ll need to create a specific User ID view, which will filter to include only the data that contains hits where the User ID value is set. Click Create to set up this view. As a best practice, you may want to include the term “User ID” in the name to help you differentiate this view. You can select a Reporting Time Zone, then click Create View.

Note that User ID Views cannot be converted to standard views, and standard views cannot be converted to User ID views. And only new views added to a User ID enabled property can be designated as User ID Views.


The User ID view will obviously have less data than a standard view where the User ID hasn’t been set, but it can provide deeper insights into the valuable segment of users who are logged in and interact with your site across multiple devices. 

When you enable the User ID feature, Google Analytics adds a User ID Coverage report. It also adds cross-device reports in the Audience section and modifies the User Explorer report.

The User ID Coverage report shows what percentage of your traffic is authenticated with a user ID. If you are introducing loyalty incentives or a more personalized site experience, you want to see the percentage of logged-in traffic rise over time.

You could also create segments that compare authenticated users with non-authenticated users. For example, the Google Merchandise Store can create two segments to compare authenticated users and non-authenticated users. For authenticated users select User-ID status and then type “assigned” in the text field. For non-authenticated users, type “unassigned” in the text field.

We can then apply these segments to the Channels report to find out if unauthenticated users arrive through different acquisition channels than authenticated users. We can also apply these segments to the Behavior Flow report, to see if there’s a difference between how these users navigate through the site. 

Once we know how much of our traffic is authenticated, we can switch back to the User ID view and use the Cross-Device Reports under Audience to see how authenticated users behave across devices. The first report is the Device Overlap report.

Device Overlap helps you understand how many users viewed your site on desktop, tablet, and mobile. It can also give you a sense of how many users access your site with more than one device.

The Device Paths report shows the sequence of device categories used to view your content. This can help you discover the order that people tend to move between devices. 

You can adjust to show steps before or after a specific category of device. You can also view paths based on their number of steps. These tools can help you better understand the results of users moving between devices.

Lastly, with this report, you can toggle to “mobile device info” to show the name of the device. This can help you understand the behavior of users across devices.

The Acquisition Device report helps you understand whether the user’s path to conversion involves multiple devices.

For example, you might find that one group of users who express interest on a desktop device, purchase an item in a later session using a tablet. This insight into user behavior across devices can help you craft your marketing strategy.

As you can see, the User ID reports can give you insight into a valuable segment of users who have willingly engaged with your site and their behavior.
 

Was this helpful?
How can we improve it?