2016-11-15



One of the biggest mistakes sites make is send visitors away to do the most important thing(s) you want them to do. For example, sending a visitor off your site to purchase something, fill out a form, apply for a job, reserve a hotel room, book a flight … You get the idea.

Why, you ask? Simple. When they leave, they take their data with them.



I identify this issue in way too many analytics audits, which is why I want to address it here.

A Tale of Two Options

When it comes to integrating data across multiple domains you have a couple options, but they’re a bit nuanced.

Option 1: Referral Exclusion List

I’ve already addressed how to rock Google Analytics’ Referral Exclusion List, and it’s an important read. At minimum, you should make sure your domain is on that list because it helps rid your account of self-referrals. You can list any other third-party or partner sites you want to include in a single session. Just keep in mind traffic from any domain or subdomain you list here will show up as direct, so you don’t want to just throw in all of your partner sites (something I’ve seen several times now in audits).

This is your best option if you either don’t need to know what the visitor is doing on the third-party site or you’re using a service like PayPal that doesn’t allow you to add your Google Analytics tracking code.

Option 2: Cross-Domain Tracking

But what if you need to know what a visitor is doing on the third-party or partner site? For example, if a visitor is converting on the external site (again, to fill out a form, purchase something, apply for a job, etc.) you absolutely need to set up something called cross-domain tracking. Adding the site to your Referral Exclusion List is not enough.

So imagine if I have a visitor on my site (I’ll call him Jared) who visits my main site, annielytics.com, and views 4 pages, then clicks through to a third-party site I’ve only excluded — awesometool.com — and views 3 pages, then comes back to my site and views 2 more pages. Google will only record 6 pageviews in my annielytics.com GA account. The 3 pageviews on awesometool.com are not included. However, if I have cross-domain tracking in place, the session will record 9 pageviews.

Also, with cross-domain tracking in place, if Jared submits a form on that third-party site, I can track it as a goal completion in Google Analytics. Same with any goal conversion or ecommerce transaction. It’s as if he never left my site because the two sites work as one.

Note: Even if you choose cross-domain tracking, you should still exclude those third-party domains by adding them to your Referral Exclusion List. It’s a built-it failsafe switch Google has given us, and I highly recommend taking full advantage of it.

So What Exactly Is Cross-Domain Tracking?

It All Starts with a Cookie

I can almost see your eyes roll to the back of your head. Fear not. I’m not going to bore you with the technical minutia of what a cookie is, how it’s stored in browsers, etc. Instead I’m going to use an analogy most can relate to: the Bridge of Death from Monty Python and the Holy Grail.

So, in simple terms, let’s say our visitor, Jared, comes to my site. He is assigned something called a client ID (Visitor ID in Google Analytics Classic). When he leaves my site and goes to another site that uses Google Analytics, he is assigned a new client ID that’s unique to that site. That’s the one first-party cookies work. You can only track a visitor’s online behavior on your site.

The Cookie’s Quest

If I use third-party tools that take visitors off my site onto an external site, the cookie that gets dropped into Jared’s browser faces challenges much like Sir Lancelot when he came upon the Bridge of Death.

His objective was to traverse the bridge without falling to his doom. But first he had to get past the troll. In our illustration the troll that guards the bridge is none other than ….

There is one thing Google wants to see: that the domain of the page Jared is coming from matches the domain (also called the hostname) of the page he’s clicking through to. If they match, Jared’s client ID will remain consistent. (Much easier than answering three elusive questions!) If not, you start from scratch with a new cookie unique to that site.

There is only one thing that will satisfy the gatekeeper in lieu of matching hostnames. It’s a single parameter that gets attached to the destination URL and carries all the cookie data with it. It looks something like this:

Aside: If you think that looks scary, you should see the cornucopia of parameters Google Analytics Classic uses:

If this mystical parameter is not offered as a sacrifice to Google, the cookie will drop. Die. Crumble. Make like a Pidgey and disappear in a poof.

How Does The Cookie Pass Unscathed?

To get this magical _ga parameter that has the power to satisfy the troll, you must take two steps:

Install your Google Analytics tracking code on the third-party domain.

Set up cross-domain tracking to carry the cookie across the bridge from one site to the other.

Back in the day we had to attach a piece of JavaScript code to every link that points to the third-party site and every link on the third-party site that points back to your site. Same with forms. It was a red-hot mess.

With Universal, Google made it much, much easier to set up cross-domain tracking. You just add an extra snippet of code to your Google Analytics tracking code that tells Google the domains you want to track as one site. It looks something like this:

Source

Then make sure all the domains — or subdomains — you want to track are using the same code.

For a deep dive into the technical details, check out this implementation guide on Google. You can also use Google Tag Manager to set up cross-domain tracking.

How to Test Your Cross-Domain Tracking

The name of the game when testing to see if your cross-domain tracking is set up properly is to check to make sure the client ID remains the same when you cross from one domain to the next. If it does, congratulate yourself. You’re a badass. If it doesn’t, fire yourself. (I’m kidding!) It just means you need to go back to the drawing board and tweak your code.

My favorite tool to do that is the Google Analytics Debugger Chrome Extension. When you install it, you’ll want to navigate to your site and open up the Console tab in your Chrome: Ctrl-Shift-J (Mac: Command-Shift-J). Then look for the client ID (clientId).

Next, cross over to the second site. With Chrome Developer Tools still open to the Console, check to make sure the clientID doesn’t change. Take note in the example below the clientId did not change.

You can see the clientId matches.

You can also just use Chrome Developer Tools by navigating to Resources > Cookies > [select site] > _ga.

Finally, you can also use the Google’s Tag Assistant Chrome extension to do this testing.

Again, if you’re still on Classic (tsk tsk), you will be looking for the Visitor ID instead of clientId.

What About Subdomains?

You do not need to set up cross-domain tracking in order to track across subdomains on your own site. The Google Analytics cookie moves from subdomain to subdomain without issue.

My $0.02

Try to wean your site off of third-party tools, especially tools that are stuck in the dark ages and don’t allow you to add your own tracking code (ahem, PAYPAL). I know from firsthand experience how daunting it is to set up your site as an ecommerce site and to eschew tools that make many tasks much easier. But, in the end, being able to own your own data is [usually] worth it.

The post Cross-Domain Tracking or Referral Exclusion List: How to Choose appeared first on Annielytics.com.

Show more