Cross device tracking with User ID in Google Tag Manager

This article is in conjunction with the article: Guide to Cross device tracking with User Id in Google Analytics, where I introduced the concept of User ID and explained in great detail about:

#1 What is User ID

#2 Difference between User ID and Client ID

#3 Benefits and limitations of User ID

#4 Session Stitching

#5 Various User ID terminologies (User ID views, User ID hits, User ID sessions)

#6 Various cross device reports

So I won’t be explaining the very basics of User ID in the present article.

I have written this article under the assumption that you are already familiar with the concept of User ID in Google Analytics and the user authentication system that you use is ‘website login’.

If you are using a user authentication system other than ‘website login’ like: biometric identification, loyalty cards, wrist bands etc then you also need to use measurement protocol and my article does not cover that.

I selected ‘website login’ as authentication system because it is most widely used. Needless to say, if you don’t authenticate users on your website then User ID is not useful for you.

Today, I will show you how to implement cross device tracking with User ID in Google Tag Manager when your authentication system is a ‘website login’.

Here is what I am going to do in a nutshell:

#1 Enable user id feature and create a User ID View

#2 Define a new custom dimension for User Id

#3 Generate User ID and push it into data layer

#4 Pull User ID from data layer into Google Tag Manager

#5 Send User ID from Google Tag Manager to Google Analytics

Get the E-book (72 Pages)

Get the E-Book (62 Pages)

#1 Enable user id feature & create a new User Id view

Step-1: Login to your Google Analytics account and then go to the Admin section.

Step-2: Click on the ‘User ID’ link under ‘Property’ > ‘Tracking Info’ as shown below:

tracking info

Step-3: Read the user id usage policy and set the toggle button to ON:

review the user id policy

According to user id usage policy, your user ids can not contain any personally identifiable data (like email address, names etc).

Step-4: Click on the ‘next step’ button twice (keeping the ‘session unification’ settings intact i.e. ON).

Step-5: Click on the ‘create’ button to create a new user id view:

create user id reporting viewYou need to create this view, as user id data can appear only in the user id view.

#2 Define a new custom dimension for User Id

This step is optional. But if you want to see user id data in your GA reports then you need to define a new custom dimension with user level scope in your GA property:

user id custom dimension

You can learn more about creating custom dimensions from this article: Google Analytics Dimensions and Metrics explained in great detail

#3 Generate User ID and push it into data layer

To generate user ids you will need to take the help of your web developer.

Ask him to write a script which generates unique IDs (any unique alphanumeric character set), assign them to each user as soon as they login, on your website and at the same time push user id into a data layer.

You can also use login ids as user ids, as long as they don’t contain personally identifiable information.

When a user login, push the user id into a data layer:

dataLayer.push({
‘userID’ : [userid],
});

Note: here [userid] is a server variable and not the variable value.

If you are brand new to data layer, then read this article: Google Tag Manager Data Layer explained like never before

#4 Pull User ID from data layer into Google Tag Manager

In order to pull user id from the data layer into GTM, you need to create a data layer variable.

Follow the steps below:

Step-1: Login to your GTM account.

Step-2: Create a new data layer variable with following specifications:

user id data layer variable

If you are not sure how to create variables in Google Tag Manager, then read this article: Understanding Triggers and Variables in Google Tag Manager V2

#5 Send User ID from Google Tag Manager to Google Analytics

In order to send user id data to Google Analytics, you need to set the user id field by editing the tag you use to deploy Google Analytics on your website.

Follow the steps below:

Step-1: Login to your GTM account and edit the tag you use to deploy Google Analytics on your website.

Step-2: Click on ‘Fields to Set’ link under ‘More Settings’ as shown below:

fields to set


Step-3
: Click on the ‘+Add Field’ button and then select ‘user id’ from the ‘Field Name’ drop down menu as shown below:

user id

Step-4: Select the data layer variable we just created (i.e. ‘pull user id from data layer’) by clicking on the ‘+’ button next to the ‘Value’ text field:

pull user id data layer variable

pull user id data layer variable2

Step-5: Click on the ‘Custom Dimensions’ link and then configure it as shown below:custom dimension google tag manager

Note: The index value of your custom dimension may not be 1. So use the one which is relevant in your situation.

Step-6: Save your Google Analytics tag, preview the container and then publish it.

Step-7: Go to your user id view and check for any new data in your ‘Cross Device reports’:

cross device reports

Step-8: Create a new custom report and use the ‘user id’ custom dimension.

That’s how you can implement Cross device tracking with user id in Google Tag Manager.

Other article you will find useful: How to identify web pages with zero traffic in Google Analytics

 

Do you know the difference between Digital Analytics and Google Analytics?


99.99% of course creators themselves don’t know the difference between Digital analytics, Google Analytics (GA) and Google Tag Manager (GTM).

So they are teaching GA and GTM in the name of teaching Digital analytics.

They just copy each other. Monkey see, monkey do.

But Digital analytics is not about GA, GTM.

It is about analyzing and interpreting data, setting up goals, strategies and KPIs.

It’s about creating strategic roadmap for your business.


Digital Analytics is the core skill. Google Analytics is just a tool used to implement ‘Digital Analytics’.

You can also implement ‘Digital analytics’ via other tools like ‘adobe analytics’, ‘kissmetrics’ etc.

Using Google Analytics without the good understanding of ‘Digital analytics’ is like driving around in a car, in a big city without understanding the traffic rules and road signs.

You are either likely to end up somewhere other than your destination or you get involved in an accident.


You learn data analysis and interpretation from Digital analytics and not from Google Analytics.

The direction in which your analysis will move, will determine the direction in which your marketing campaigns and eventually your company will move to get the highest possible return on investment.

You get that direction from ‘Digital analytics’ and not from ‘Google Analytics’.


You learn to set up KPIs, strategies and measurement framework for your business from ‘Digital analytics’ and not from ‘Google Analytics’.

So if you are taking a course only on 'Google Analytics’, you are learning to use one of the tools of ‘Digital analytics’. You are not learning the ‘Digital analytics’ itself.

Since any person can learn to use Google Analytics in couple of weeks, you do no get any competitive advantage in the marketplace just by knowing GA.

You need to know lot more than GA in order to work in digital analytics and marketing field.


So what I have done, if you are interested, is I have put together a completely free training that will teach you exactly how I have been able to leverage digital analytics to generate floods of news sales and customers and how you can literally copy what I have done to get similar results.

Here what You'll Learn On This FREE Web Class!


1) The number 1 reason why most marketers and business owners are not able to scale their advertising and maximise sales.

2) Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

3) The number 1 reason why conversion optimization is not working for your business.

4) How to advertise on any marketing platform for FREE with an unlimited budget.

5) How to learn and master digital analytics in record time.

 
 

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and Beyond
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

Himanshu Sharma

Digital Marketing Consultant and Founder of Optimizesmart.com

Himanshu helps business owners and marketing professionals in generating more sales and ROI by fixing their website tracking issues, helping them understand their true customers purchase journey and helping them determine the most effective marketing channels for investment.

He has over 12 years experience in digital analytics and digital marketing.

He was nominated for the Digital Analytics Association's Awards for Excellence.

The Digital Analytics Association is a world renowned not-for-profit association which helps organisations overcome the challenges of data acquisition and application.

He is the author of four best-selling books on analytics and conversion optimization:

error: Alert: Content is protected !!