Implementation Of User Id Via GTM & Benefits

  • Mar 14, 2018

  • by Saurabh Kumar

0
Get in
touch
Implementation Of User Id Via GTM & Benefits

I realise we have all always wanted to know how visitors actually interact on our website through different devices. For example, what are the combination of devices through which they come and get converted here as leads for us. Additionally, the lifetime value of different user types and differences between members & non-members are not available in any basic GA reports.

This happens because in a regular view of Google Analytics, the counts of users and sessions are separate if the same user enters our website using an iPad, a desktop, or/and an Android mobile phone.

To handle this problem and to give more accurate user and session counts, Google Analytics came up with the feature "User Id" through which we are able to unify the sessions that a single user is making using different devices, into one user in Google Analytics.

Here is the Step-by-Step guide to implement User Id tracking via GTM:

Step 1 - User-Id tracking enabling in Google Analytics

  • Switch to the Settings of the Google Analytics account for which you want to implement User-Id tracking. You have to switch on the button under the section ‘Review the User-Id Policy’ which says “I agree to the User-Id Policy”.
  • After enabling the User-Id feature, you will have to create a new User-ID view for the same GA property in which you are going to implement user-id tracking. Note that this new view that you create here will only be used to display data for logged-in users.

Step 2 - Create a new Variable in GTM to retrieve the logged-in user-Id

In GTM, retrieving a variable can be done by various ways, and here, we’ll retrieve a logged-in user’s userId that was stored in a cookie which was set by your site’s login system.

Following are the steps to do this:

  • Create a new Variable in GTM, name the variable “User ID”.

  • Select “Custom Javascript” as the variable type.

  • Write a JavaScript function that retrieves the userId variable from your site’s login cookie. The retrieval of your userId variable depends on your site’s particular setup so you’ll need to write your own function here to retrieve this data. Important: the end result of your function should return just the identifier that you want to pass to Google Analytics as the userId.

Note: Google’s terms of service prohibit using personally identifiable information as a userId, don’t use names and email addresses.

Step 3 - Create a new Tag in GTM that will fire on each page view, setting the userId

  • Create a new Tag, name it “userID Tag“.

  • Select the GA Tracking ID for the profile you enabled User-ID tracking for in step 1.

  • Under more settings, set the Field Name to “userId“. Set the value to “{{user id}}“.

  • Set the triggering to All Pages.

Step 4 - Check your work in the Preview mode

  • Put your GTM container in the Preview mode to verify that your tag is firing and that the userId is getting passed.
  • If your userId is being captured in the Preview mode, you’re ready to publish your work! If not, check your JavaScript function in step 2.
  • Kudos! You can now view your userId Tracking (accurate counts of users and sessions) in the User-Id view of Google Analytics.

Note:The data in this User-id tracking view updates every 10-15 minutes.

Benefits of Implementing User ID Tracking

So, you have learned to set up User-id tracking via GTM, and hence you should know the four main benefits of that:

  • Accuracy in User Counts- This new User Id view allows GA to show an accurate counts of users/sessions by putting same users in one Id if they visit the website by multiple devices.
  • Data segmented by logins- Typically, registered users behave differently than those who do not sign up (or sign in). User ID tracking allows you to compare the behavior of logged-in users with “guests.”
  • More reports in GA- User ID tracking creates an entirely new view that collects only unique user data. The more granular reports in this view aren’t available in regular GA views.
  • Relationships between devices and engagement- New views include Device Overlap, Device Paths, and Acquisition Device.

Let's Work Together

Begin With a Free Quote

About author

Saurabh Kumar
  • Saurabh Kumar

A marketing enthusiast with a fascination for technology, an interest in tinkering with data and systems, and 4+ years of experience at ebookers, Saurabh Kumar Founder Envigo, a digital marketing agency, in the year 2007. His passion for Digital Marketing led him to launch a data-driven digital marketing solutions agency.

View posts by Saurabh Kumar

You might also like

Start your project


  • No comment added.
Download