Cross‑Domain Tracking With Google Tag Manager

December 24, 2013

Keep calm and _setAllowLinker on

UPDATE: Looking for instructions on cross-domain tracking with the new version of Google Tag Manager? Check here:

Cross Domain Tracking with Google Tag Manager (V2)


Cross-domain tracking has been the bane of any analyst’s experience for, oh, just about ever. It is probably the hardest thing to get right in a Google Analytics implementation, and in our experience, more people ask us for help with this one issue than any other.

Over the years we’ve dealt with this problem in different ways. jQuery made it easy to drop in a couple lines of code to track behavior across domains, but even then it wasn’t exactly automatic.

Then along came Universal Analytics and Google Tag Manager – the perfect 1-2 punch combo to knock out cross domain tracking once and for all. We held a webinar to show people step-by-step how to implement cross-domain tracking in Google Tag Manager. Below is a recording of the webinar, along with the written step-by-step instructions.

*NOTE: Since the webinar, there have been some updates to Google Tag Manager and Universal Analytics that make cross domain tracking even easier and more intuitive. If you follow the directions in the webinar, it will still work. But the written instructions below are up to date with the newest features.

 

Step-By-Step Instructions – Universal Analytics

The following instructions will guide you to setting up cross-domain tracking through Google Tag Manager with Universal Analytics.

Create the following macros

1. uaid

uaid

* For the value, replace the Xs and Yx above with your UA number.

2. cross domains

cross domains macro

3. element url (if you don’t already have it)

element url

 

Tagging cross-domain links

Create a tag for your Universal Analytics tracker (I recommend naming it Google Analytics – Universal). The Track Type for this tag should be Page View. If you already have a tag for Universal Analytics, modify it to match the following settings:

1. For Tracking ID, use your uaid macro

tracking id

2. Under More Settings > Cookie Configuration, set the value of Cookie Domain to auto.

auto cookie domain

* This step has changed since the webinar was recorded. In the webinar we say to create and use a {{top level domain}} macro for the Cookie Domain value. Now you can simply use auto, as pictured above.

 

3. Under More Settings > Cross Domain Tracking, set the value of Auto Link Domains to your cross domains macro, and set the Allow Linker drop down menu to True.

auto link domains

* This step has changed since the webinar was recorded. You used to have to go into Fields to Set, and add a Field Name of allowLinker with a value of true. Now you can just use the drop down menu pictured above.

 

4. Set the firing rule for this tag to All pages.

all pages

 

 

Tagging cross-domain forms

1. Create tag – name it Form Submit

form submit

 

2. Create tag – name it Cross-Domain – Forms

A. Create a copy of your Google Analytics – Universal tag. To do this, click on your Google Analytics – Universal tag and scroll to the bottom. In the lower right corner, click on the Copy this tag button.

B. Name your new copy Cross-Domain – Forms.

C. Change the Track Type to Decorate Form.

decorate form

 

D. Remove the All pages rule and add the following 2 rules (which you will need to create):

i. On Form Submit to siteA.com

form submit rule 1

ii. On Form Submit to siteB.com

form submit rule 2

 

Update web property settings

Go into your Google Analytics Admin settings. Under Property Settings, Tracking Info > Referral Exclusion List, add both sites (if not already added).

referral exclusions