Blast Analytics and Marketing

Analytics Blog

Supporting Leaders to EVOLVE
Category: Digital Analytics

2 Simple Steps to Cross Domain Tracking in Universal Analytics

November 24, 2014

Cross domain tracking has been one of those thorns in Google Analytics implementations. Although, it isn’t technically that complicated, there are many things that can (and usually do) go wrong.

For most implementations, it isn’t much of a problem once the initial implementation is figured out. However, for the larger enterprise level companies with an expanding number of websites, it can get to be one of those persistent thorns you have to keep an eye out for.

Fortunately, Google’s Universal Analytics simplifies the setup process, and we’ve provided some valuable tips in this article that will help you solve common needs and avoid typical issues.

Why is Cross Domain Tracking Important?

In case you aren’t familiar with cross domain tracking, it’s mainly used when you have scenarios where people are moving between domains, and it’s important for the session (and visitor identification) to be retained. This is especially true when you have a website with a checkout process hosted on a separate or secured domain.

If your Goals or Conversions take place on the separate domain, you will lose traffic attribution data unless your implementation is configured properly for cross-domain tracking. The adverse impact on your reports is that they will show most all conversions tied to either direct traffic or the domain itself (which is considered a self-referral).

I’m pretty sure tracking the source of your conversions is vital, so you can evaluate the effectiveness of your marketing campaigns. So let’s talk about how to fix this.

Two Step Process for Cross Domain Tracking in UA

Universal Analytics, along with all the wonderful new features has truly simplified this process. It’s down to a simple 2 step process:

STEP #1: Exclude Self Referrals

You need to configure your Google Analytics property to ignore the domains you are looking to track across within the admin section of the Google Analytics web interface under “Tracking Info > Referral Exclusion List”.

On the Referral Exclusion List page, click the ‘+ Add Referral Exclusion’ button and add your origination domain (e.g. maindomain.com) and target domain (e.g. targetdomain.com) to the list (as shown below).

2014-10-10_16-50-29

STEP #2: Modify Tracking Code

Make the following changes to your Google Universal Analytics Tracking Code:

  • Set “allowLinker” to true on the domains involved (shown in line 6 of sample code below)
  • Add a line of code to include a “linker” plugin (shown in line 8 of sample code below)
  • Set the “linker” to “autoLink” and provide an array with all of the domain names to cross domain to (shown in line 9 of sample code below)

Sample Code

To help you further, here’s some sample Google Universal Analytics code to serve as a reference for our provided cross domain tracking changes. Feel free to grab and use as you desire:

Code Option 1: Hash/Anchor

As an option, if you want to have the autolinker use a hash/anchor (#) instead of passing the cookie info as a query, modify the linker:autolink line of code by adding a “true” at the end like this (Note: In this configuration, you don’t have to set allowAnchor for cross-domain to get this working):

ga(‘linker:autoLink’, [‘maindomain.com’,’targetdomain.com’], true);

Code Option 2: Add Form Support

If you want your forms to handle cross domain linking, modify the linker:autolink line of code (which is line 8 in the Sample Code above) by adding another “true” parameter as shown below:

ga(‘linker:autoLink’, [‘maindomain.com’,’targetdomain.com’], true, true);

Caveat Emptor

Last thing, a bit of a warning. This may not work on pages with particular methods of linking. More specifically, it would not work if:

  • your site has JavaScript within the href of the link to load the link, instead of a clean URL (example below)<a id=”ApplyButton” class=”apply top” href=”javascript:doSomething();”>apply</a>
  • you have an element with an “onclick” attribute, the URL specified in the onclick (example below)<a id=”ApplyButton” class=”apply top” href=”#” onclick=”doSomething()”>apply</a>

In either situation, the doSomething() function will probably have a return false or preventDefault() to keep the anchor from working normally. The function will do something and then redirect the page to the desired URL. You’ll need to modify your doSomething() function to use a decorated URL. See the “Decorate Utility Method” on the Google Developers pages.

Finally, you’ll want to be aware of the following:

  • If you are migrating from Classic Google Analytics to Universal, don’t be alarmed when you don’t see those __utm* parameters after the cross domain jump. Google has simplified this so that you’ll now see a single querystring parameter named ‘_ga’.
  • By using the linker param via autoLink or the other methods that Google provides, you’ll solve another issue that is created when a user shares the link with the cross-domain parameter with a friend. The friend can show up as the same user as the original user which causes interesting issues in data quality. Google fixes this by placing a hashed timestamp in the _ga parameter that expires after 2 minutes.

Now sit back and reminisce with a smile about the times when you had to worry about creating a JavaScript or jQuery script to capture anchor links leading to the domains and how there was always that one link or two that would fail to work. Cheers to all of those Google Analytics Implementation specialists who share the pain of the old way of doing things and are jumping for joy at the beauty of the new method. Thanks Google!

If you have questions or comments, we encourage you to post below. If you’d like even more details on cross domain tracking, the Google Analytics team does a great job in documenting all of the capabilities of Cross Domain Tracking.

Olaf Calderon
About the Author

Olaf is the Director of Implementation at Blast Analytics & Marketing. He and the implementation team, handle configuration, installation and training of analytics tools. He spends the majority of time developing tracking code and He loves the challenges that every project presents and is always finding more efficient ways for our clients to collect, read and analyze their data. His passion is developing tools, processes or methods to make everyone's life easier.

Olaf Calderon has written on the Blast Digital Customer Experience and Analytics Blog.

Related Insights

business meeting discussing analytics

Digital Analytics

December 16, 2021

We’re here to help with tips and insights on the following topics:

Data Management Digital Analytics Digital Experience Digital Transformation Marketing Activation User Privacy
HIPAA and Analytics White Paper CTA

Featured White Paper

Healthcare Analytics and HIPAA: Ways to Minimize Risk and Ensure Compliance

The rise in digital data and analytics adds complexity and risk for healthcare organizations. Those that don’t comply with data privacy requirements, including Health Insurance Portability and Accountability Act (HIPAA), could face heavy fines, civil action lawsuits, and even criminal charges. Not to mention loss of patient trust.

Download the White Paper

Ready To Do More With Your Data?

If you have questions or you’re ready to discuss how Blast can help you EVOLVE your organization, talk to an Analytics Consultant today.

Call 1 (888) 252-7866 or contact us below.