Menu
  • who we are
    • our team
    • careers
    • rva city guide
  • what we do
    • pay per click (ppc)
    • search engine optimization
    • landing page optimization
    • content marketing
    • conversion rate optimization
    • digital pr
    • reporting & kpi tracking
  • work we’ve done
    • case studies
    • client success stories
  • our blog
    • seo
    • ppc
    • analytics
    • google tag manager
  • contact us
Analytics

How to Set Up User ID Tracking in Google Tag Manager

Alumni
Updated:
April 6, 2018
Published:
April 18, 2016

Every day, we rely on Google Analytics (GA) to make data-driven decisions, the results of which depend heavily on data accuracy. Although GA provides many valuable insights, 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 an already segmented 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 inaccurate your data may become.

GA is a great tool to provide a useful picture of your audience as a whole, but it does not provide as much detail on individual user interactions on your site. For example, the combination of devices used before a conversion, the lifetime value of different user types, and differences between members and non-members are not available in any basic GA reports. Even the number of users and sessions may be reported inaccurately in your current GA view.

We’ll explain why the user count is inaccurate in GA, the benefits of tracking user engagement, and how you can track individual users to gain new insights.

Why use User ID tracking?

GA already captures an ID for every user that visits your site, which is called a Client ID. However, a Client ID is not specific to browser and device types; a User ID is. In the regular GA view, the same user can enter your site simultaneously through Safari on an iPad, Chrome on a desktop, and via their phone, and it counts as three separate users and sessions.

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.

Screen Shot 2016-04-18 at 11.49.44 AM  Screen Shot 2016-04-18 at 11.49.34 AM
Aside from the benefits of more accurate user and session counts, why should you implement User ID tracking on your site? Group characteristics may suffice for smaller sites that do not use e-commerce tracking or endure skewed reports from sampled data. However, for large e-commerce sites with thousands of daily visitors, User ID tracking promises unique insights not available in regular views.

Benefits of User ID Tracking

There are four main benefits to User ID tracking:

  1. More accurate user count. The new view allows GA to stitch together sessions previously separated by multiple entry points.
  2. 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 to “guests.”
  3. 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.
  4. Relationships between devices and engagement. New views include Device Overlap, Device Paths, and Acquisition Device.

Think these new reporting capabilities could improve performance on your site or better allocate outside marketing efforts? Read on to learn how to set up User ID tracking easily in Google Tag Manager (GTM).

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 a login for returning customers.

Every page should contain (at least) two of the following codes in this order:

1. Universal Analytics code. Classic Analytics does not support the User ID feature, so migrate your site to Universal Analytics before setting up User ID tracking. (Ignore this step if implementing GA tracking through GTM.)

2. dataLayer script. This will push user ID data to your GTM container, which will look like this:  
<script>dataLayer = [{'userID': '12483'}];</script>

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 the login.

3. GTM container. Placed after the dataLayer script.

How to Set up User ID Tracking with Google Tag Manager

GTM is the easiest and most popular method to set up User ID tracking. Set up the GTM container to capture the unique User ID through a cookie or data layer variable. This tutorial focuses solely on the data layer method because it doesn’t require pre-established cookies.

After the above three codes have been placed on every page of the site, set up the GTM data layer variable and tag.

First, create a new data layer variable and configure it to collect data from the dataLayer script by assigning the name “userID”.

userid

Once you have created a data layer variable, set up the tag. Set your tag’s product as “Google Analytics,” tag type as “Universal Analytics,” and attach the Tracking ID of the property you wish to track. The track type will be set as a pageview that fires on all pages because it acts as a “general data collecting” tag that will associate any and all hits with an assigned User ID.

Set custom fields to avoid double counting all hits that aren’t associated with a logged-in user. Open up the “More Settings” drop-down menu to 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, which will show up in regular reporting views, as seen below:

Screen Shot 2016-04-18 at 11.58.36 AM

Once you’ve finished the tag, it should look like this:

Screen Shot 2016-04-18 at 12.12.10 PM

Ta-da! The “hard” part is over. Just enable User ID tracking in your GA property and define the custom dimension to sort your data by User IDs.

userid3

In the Google Analytics Admin section under Property Settings, find “User-ID”. Agree to the User ID policy that states that you won’t upload any personal information along with the data you collect. Also, remember that you must let users know you are tracking them at an individual engagement level. Add a line or two in your privacy policy, and you should be set.

You also have the option to turn on Session Unification. 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. The new User ID view will display data only from users assigned User IDs.

If you added in a custom dimension to your GTM tag in the previous step, identify the custom dimension in GA as well. Under “Custom Dimensions” in Admin, set the dimension’s name and scope. Use the exact name specified in the GTM tag and the scope “user”, since we are sorting by user-level data.

userid6 userid7
Once you’ve taken these steps, you should have your new User ID view with individual user data only, and a custom secondary dimension in remaining 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 information 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.

Curious to discover how tracking individual user data can benefit your site? Contact us today to get a free audit.

 

Latest Comment

With the update to GTM and its interface, I am having difficulty following these steps. It's now a different setup for tags and I do not see the option to set fields as an advanced option. Please help! Thank you :)

Gina

–Gina
  • Read All Comments
  • Leave A Reply

Comments

  1. Will H says

    March 7, 2017 at 11:39 am

    Great guide. I had some initial trouble setting up, but this was most helpful. Thanks Oeuyown!

    Reply
  2. Marine says

    May 11, 2017 at 4:27 am

    Thanks for a clear and great guide!

    Reply
  3. cathal says

    May 11, 2017 at 8:45 am

    Thank you so much for your tutorial on this, it really is making more sense to me now.
    Unfortunately we are getting the “userID” as “Undefined” when following the steps
    If you could offer some guidance or Help on what we may be doing wrong we would be very grateful!

    Here is a screen shot of the Preview mode in GTM

    http://prntscr.com/f6lcl2

    Kind Regards

    Reply
    • Oeuyown Kim says

      May 12, 2017 at 3:28 pm

      Hi Cathal,

      I’m glad my post was helpful! I looked into the domains listed in the screenshot you provided and did not find a dataLayer set up for “userId”. However, it may be due to the limited information I have publicly.

      I would check for the following:
      – There is a dataLayer set up to populate the correct information for “userId”
      – This dataLayer is placed above your GTM container in the source
      – This dataLayer is spelled exactly the same with the same capitalization, “userId”, as specified in the GTM dataLayer variable

      If you’ve checked for all of these and your field is still coming up as “undefined”, please feel free to contact me directly at oeuyown@workshopdigital.com! I will need more information than I’m able to gather publicly to debug this issue.

      Thanks!

      Reply
  4. Ateeq Ahmad says

    July 7, 2017 at 11:47 pm

    Thanks so much for the steps. I have a quick question. The variable name should be the same throughout, is that correct?
    In the instructions to create the dataLayer you are using userID. When defining the variable, you are using userID also.

    However, in the tag, you are naming it userId and doing the same in the custom dimension in Google Analytics. Is this on purpose.

    I ask because i have made my variable as userID all over the place and the view is not populating at all.

    Reply
    • Oeuyown Kim says

      July 10, 2017 at 1:12 pm

      Hi Ateeq,

      Thanks for your comment! The GTM variable name must match the dataLayer name exactly, which is “userID.” Where you see me use “userId” is simply to name the custom dimension field that appears in Google Analytics. It’s okay to set the field NAME as something different as long as the VALUES are the exact userID dataLayer variable you created.

      In the custom dimension settings in your UA tag, did you pull in the userID variable or just define the value yourself? {{userID}} is the correct value whereas “userID” would not pull in anything. I hope this helps!

      Thanks!

      Reply
  5. Ateeq Ahmad says

    July 17, 2017 at 1:04 pm

    Thanks so much for the response. I got it working using some of your explanation and some hit and trial. There is a problem with the userid case. I am afraid, there is some hard coding needed on my end. I don’t know if that is universal. Please see my steps here. http://ateeqahmad.com/wordpress/2017/07/13/track-userid-google-analytics/

    Reply
  6. Tomasz says

    September 29, 2017 at 8:27 am

    Thank You! That is what I just was looking for!

    Reply
  7. Gina says

    May 13, 2018 at 9:13 pm

    With the update to GTM and its interface, I am having difficulty following these steps. It’s now a different setup for tags and I do not see the option to set fields as an advanced option. Please help! Thank you 🙂

    Gina

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Who We Are
  • What We Do
  • Work We’ve Done
  • Our Blog
  • Careers
  • Privacy Policy

© 2019 Workshop Digital (804) 303-2883