Wow, that title is a mouthful. Let me get to the point. Cross-domain tracking for Universal Analytics with Dynamic Tag Manager is broken. I think. For those of you using Google Analytics with DTM and your cross-domain just isn’t working out: this post is for you. I spent several hours debugging some cross-domain tracking. What do you need to do to enable cross-domain tracking?
- Ensure you have added all of your domains in your “Edit Property” page in DTM (see below the “Publish” button, admins).
- Check the box that says “Allow Linker Link” in your Universal Analytics settings
That’s it, really. Just 2 steps and it should work (once you have published the property). There are 2 things going wrong here. First of all, DTM doesn’t flag changes made on the web property level as something that needs a publish. It does. So if you have added multiple domains to your web property… publish your property. I guess this would matter if cross-domain tracking actually worked.
I was lied to. Debug mode told me that everything was functioning as intended…
But when I clicked on any link going between domains there was nothing. My expectation was that I would see a query string that would look something like the following: url.com/?_ga=2131.123.1223.123
That common key (user/session ID) is what ties the sessions together. So how do you fix this? It’s quite simple, really.
- Go to your Google Analytics settings in DTM (that gear next to your tool info).
- Click on “Customize Page Code” and click “Open Editor”.
- Use the following code:
ga(‘yourtrackername.linker:autoLink’, [“yoururl.com“, “yourotherurl.com“]);
“yourtrackername” is that hash string that’s in Customize Page Code drop-down.
“yoururl.com”/”yourotherurl.com” are the domains that you want to track across domains.
That should do it! If you’re experiencing the same issue I was, I hope this helps.
how to track time spent on a section?
how to track device type? whether desktop or mobile and if mobile which mobile ?