Tracking a single user behavior

Tracking a single user behavior

The biggest advantage of Kissmetrics, Localytics, Mixpanel and other marketing tools over Google Analytics, is tracking a single user behavior. Means you can track the behavior of a specific user. See all of his clicks, the pages he viewed, drill into the second this event happened.

I would like to show you, how with a simple implementation in Google Analytics (using Google Tag Manager) you can drill into a specific user, track his behavior in a resolution of milliseconds.
After you complete this tutorial you can go even more advanced and add the time to event as guided in the Calculating the time-to-event metric in Google Analytics article

Tracking a single user behavior in Google Analytics

No need for coding knowledge, just follow these 5 simple steps:
1. Creating a userID variable in GTM
2. Creating a timeStamp variable in GTM
3. Creating 2 custom dimensions (UserID, timeStamp)
4. Firing the variables from GTM to GA
5. Creating a custom report in GA to present the data

1. Creating a userID variable in GTM

When I say userID I mean the Cookie ID. If you look at the cookies you have on your website, you will see one that looks like this:
Tracking a single user behavior - locating the Google Analytics cookie ID
Thia meant that in case a user doesn’t identify himself or he didn’t sign up yet or even further than that, you don’t have user authentication in your site, you can still identify the user by his Cookie ID.
In case you have a userID variable in GTM you may want to call this variable CookieID.
Under Variables create a new Custom JavaScript variable.
Tracking a single user behavior - Creating a userID variable in GTM
Insert the following code:
function() {
var userID = ga.getAll()[0].get(‘clientId’);
return userID ;
}
– This means that you fetch the cookieID value and retrun it in as the variable.
Name it as UserID and save.

2. Creating a timeStamp variable in GTM

Similar to the previous step of creating the userID variable, go to Variable -> New -> Custom JavaScript.
Tracking a single user behavior - Creating a timeStamp variable in GTM
Insert the following code:
function() {
var now = new Date();
return now.getTime();
}
– This means: get the current date as epoch time and retrun it in as the variable.
Name it as timeStamp and save.

3. Creating 2 custom dimensions (UserID, timeStamp)

Now we need to prepare the custom dimensions in GA so that GA will know where and how to store these new custom dimensions.
Please follow these instructions:
Tracking a single user behavior - Adding custom dimensions in Google Analytics
1 – Under Admin
2 – Enter the Custom Dimensions section
3 – Create a new custom dimension
The UserID should be User scope, and the timeStamp should be Hit scope.
– Remember the Index of every custom dimension

4. Firing the variables from GTM to GA

Back to your Google Tag Manager account, go to your tag that you fire pages/events to GA.
– You can also go to the Google Analytics Settings variable and insert the custom dimensions there
Tracking a single user behavior - Firing custom dimensions to GA though GTM
Go to the Custom dimension area, under More Settings. Insert the index of the Custom Dimension that you created in GA (step 3) and the variable you created in GTM (steps 1 & 2) in the Dimension Value box.

5. Creating a custom report in GA to present the data
The final step for Tracking a Single User Behavior in Google Analytics is creating the report in GA.
Let’s create the following custom report:
Tracking a single user behavior - Creating a custom report in Google Analytics
Under the dimensions select the userID all of the event hierarchy you want in the order that best suits you and the timeStamp dimension
Under the metrics let’s select the total events
– You can do the same also for pages: entrance, pageview, and exit.
Now you can filter a specific user in the report you just created (order the report by timeStamp – ascending), track his behavior and drill into the second each event happened.

Learn Google Analytics, at your own pace, from wherever you are, with the best platform!

Start the course now (free)