Setting up the XDID in Google Tag Manager i super simple and requires only a few steps. In the guide I will cover how to create the correct.
XDID generates a unique non identifiable id, which can be used with Google Analytics to enable user view reports. The usage of XDID is much wider than this, but this guide will show the simple steps to enrich your data and to give you the ability to make targeted marketing decisions.
- How to bind it correctly with Google Analytics
First you have to create the variables needed to get everything running. For the sake of this guide, I will asume that Google Analytics is already setup.
1. Create Cookie Consent Variabe (if you not allready have this) This variable is used to make sure that XDID is not called until consent i given. in this guide I will set it to true as a default value, but you should hook it into your favorite Cookie Consent system. I suggest CookieBot
2. Create the Undefined variable. This is a built-in type in GTM
3. Create an XDID variable like in the illustration below
4. Next create an XDID Assigned variable using the same procedure as above, but set this default value to false
5. The last Variable is a Cookie Consent Lookup table, which is used to get the actualt status of the user consent. Remember that we set it default to true. if you have an other variable allready then you can use that in this Lookup table and remove the one created in step 1
In this section you will be creating the trigger used to secure that XDID gets called before Google Analytics
1. Create a trigger called “Custom Event Trigger – Wait for XDID” like this. Make sure to set the event name to xdid.assigned. Not the same name as the variable. this is an event.
2. Create a new Trigger called “Windows Loaded trigger” like this
Thats it for the triggers. Super simple right.
1. First create the XDID tags, using a Custom HEML Template. The code yoiu will find inside the xdid.net app along with documentation on how to configure it
Set the trigger to All pages.
2. No you need to either create and configure or re-configure your Google Analytics tag. Its really simple and all you need to do is this
Basically all you need to do is to change the trigger from All Pages to the one you created above. this forces the Google Analytics to initialize after the xdid is generated, which will make it possible to assign UserId to your sessions
3. Last step is to configure the Google Analytics Variable to use the XDID
This is done like this. Pay attention to the extra field and the lookup variable.
Thats it. You are done. Now you should be able to test the GTM Tags in Preview and see that it fires correctly.
I suggest you use the Google Chrome Plugin called Google Tag Assists, which is any easy way to see if the user Id gets set. It should look something like this