If you use user authentication, loyalty programs, or at least dynamic remarketing on your site, then you should already be familiar with such a concept as User ID. We choose a login and a regular userd id, which is assigned during registration, since this is the most popular option.
We decided to find the simplest and fastest way to implement cross-device tracking on the client’s website and used GTM, as always
What must be done, in order:
- Include User ID in Google Analytics and create a separate view.
- Create a new custom dimension for User ID.
- Generate User ID push and add it to data-layer.
- Pull User ID from data-layer using GTM.
- Send User ID data to Google Analytics using GTM.
Let’s start in order with the simplest. We go into our Google Analytics, go to the admin panel and in the resource column we find: tracking code – >> user-id:
Go to the section and enable user tracking:
Be sure to enable session pooling, since this will allow you to associate with identifier hits that were received before the User-ID was assigned.
And finally, we create a new view for the User-ID, in which we will view statistics. The view can be used as an auxiliary, but not the main one. In the new view, you will have a cross-device section:
Now we need to create a custom dimension to pass our User ID parameters:
In the current data layer on the site (most likely you already have it), add another parameter that will transfer the value we need. The parameter should be processed when the user is authorized. It will look something like this:
Now we need to set up the GTM side. Here, too, everything is extremely simple. Add a new variable, let’s name it “Pull user id from data layer”:
And we set up a new tag. The tag will work on all pages, we set the following conditions:
We publish the tag and after a while we will be able to track the metrics in Google Analytics in the following form: