Uncategorized

UserID tracking in Google Tag Manager(GTM)

uid_gtm

Why do we need to do that?

Ostensibly Google says that you do this for tracking true users of your site. Since multiple devices generate a visitor cookie each, they get counted as different visitors. You can stitch sessions cross-device by creating a userid view.

However, if we want to track CAC and LTV by referral sources and we have only Google Analytics and an internal database around, we can piggyback on this method to measure them.

It is tricky and will require some testing before it runs in your environment. However, it works and I have managed to figure it out in Google Tag Manager and will lay it out for you dear analyst, step by step.


Step 1

Create the User-ID view in Google Analytics. Go to the Property and expand “.js tracking Info”. Then follow the prompts as seen in the picture below.

uid_gtm_02

After you have done the above, let’s create a dimension to store this data.

Step 2

In the same property column, below the PRODUCT LINKING tab, sits a place to create custom dimensions as shown in this picture below.

uid_gtm_03

Click on create dimension and add the custom dimension as shown below:

uid_gtm_04

Please note that you have to name it userID. This is because I am going to name the data layer variable later the same. They have to be so to capture your user information.

Step 3

Have your awesome developer pass the user-id value to the data layer variable called userID. The values that it should spit out if you click “view-source” on your site should look like this:

dataLayer = [{‘userID’: ‘yyyyyy’}];

dataLayer.push( {‘event’:’uidAvailable’, ‘uid’:’yyyyyy’} );

They can push this change live anytime and will be quite thankful for the Starbucks drink you will treat them to.

Make very sure that this userID being made cannot be Personally identifiable information(PII). So no names, email addresses, etc.

Step 4

Ok! Let’s push on now to the Google Tag Manager and the last part of this implementation.

Open up your tag manager and on the left hand side where it says, variables, click and add a user defined variable. We will call it userID.

uid_gtm_05

Now, on the left hand side open up the tags section. On all the tags that have anything to do with an event or page view, we will make slight edits. Let’s start with the Google Analytics tag (it should be set to universal Analytics otherwise this will not work).

uid_gtm_06

We add two variable to be filled when the tag fires, one is the userId (please note that this is the exact name you need to set). The other is the custom dimension that we have created in Google Analytics so we can run reports based on our own user-ids, which I am sure, are aligned to email addresses.


Step 5

Now, let’s set our workspace on Google Tag Manager to Preview the changes that we have made. If this works, the Real-Time reports in Google Analytics will immediately start collecting data. Once it works, then go ahead and publish the new tags.

Now, you should be free to download the userID and referral source. You can download the LTV and userID from your own database and analyze in Excel or any other spreadsheet of your choice.

You would have noticed that I keep harping on the name and case of the variable “userID” and “userId”. I thought to name all variables the same and it didn’t work. However, hard-coding the variables works perfectly!

Do let me know if you have any issues with this and I can walk you through the implementation, if need be.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s