The Curious case of Google Analytics Cross-Domain Tracking

A recent call from a past client reminded me of an interesting use case worth sharing.

Act One — Anticipation

The story began back in October 2017.

I had just left the ad agency I was working at and switched over to the relaxed client-side life as an in-house Digital Marketing manager.

One day while I’m at the office, I received a phone call from an unknown number.

“I’ve got your number from a mutual friend”

said the man on the other side of the line

“We have a tracking issue we can’t solve. I can’t tell where my conversions are coming from!”

The client was a luxury hotel chain managing several web properties. Each of their two brands had a dedicated website, split across two domains, one for each language (Hebrew & English). So overall they had four internal domains to manage:

  1. hotel-a.com
  2. hotel-a.co.il
  3. hotel-b.com
  4. hotel-b.co.il

Aside from the multiple client domains, the reservations were handled on a third-party site, so the conversions were ultimately happening there. For sake of simplicity, let’s call it reservation-site.com

Classic cross-domain setup.

“Let’s rock and roll”

via GIPHY

Act Two — Dream

Implementing Cross Domain tracking is a pretty straightforward procedure. Just follow the technical steps and you should be finished in a few minutes.

Since the client had several different sites that weren’t part of a single user journey, we started out by mapping how users are expected to travel across domains.

The logical map was:

hotel-a.com -> hotel-a.co.il -> reservation-site.com

(for users switching across languages)

A similar mapping was also relevant for Hotel B.

Conveniently enough, the client had Google Tag Manager (GTM) implemented across all his properties (including the reservation site), which made everything faster to deploy.

All three domains were added to the GA Pageview tag as ‘Auto Link Domains’.

Adding the domains in GTM

Also in GTM, the allowLinker field was set as ‘true’.

Instructing the tracker to respect incoming decorated links

Additionally, all three sites were added to the Referral Exclusion list in GA.

Adding the domains to be excluded in GA

“Piece of cake 😎”

Act Three — Frustration

Although I’ve done this procedure numerous times, I still like to refer to Simo Ahava’s checklist.

Credit: Simo Ahava

You can find his full blog post here.

Checking the implementation, I noticed that when switching across hotel-a.com & hotel-a.co.il was working as expected, but switching from either of them to reservation-site.com wasn’t passing the _ga parameter in the URL.

“Houston, we have a problem!”

After running several validations to make sure the setup was done correctly, I still couldn’t find the reason it wasn’t working.

So it was back to the drawing board.

via GIPHY

The basic gist of Cross Domain tracking is taking the existing Client ID (CID) value from the current domain’s cookie and concatenating it to outbound links using a simple JS function.

GTM and GA can both run this function out of the box which is why I was surprised to see that it wasn’t working as expected.

So I examined the client’s website again in search of the culprit.

“Eureka!’” (and facepalm 🤦🏻‍♂️)

The outbound links leading to reservation-site.com were generated dynamically. This is due to the fact that the user had to be sent across to the reservation site with certain parameters, i.e. number of adults, date range, etc.

This meant that the links didn’t exist in the HTML document, to begin with. And even if they did, they would have been replaced with a new one once a user refines the date range or other parameters.

Act Four — Resolution

The solution to this issue was relatively simple but required some development from the client’s team.

Basically, we had to imitate the autolinker’s behavior by extracting the CID from the cookie and adding it to the outbound URL.

Since the client was using GTM, we couldn’t use GA’s built-in method to extract the CID but rather had to pull it out manually.

This isn’t a complex task using JavaScript but does require some attention as the CID is stored in the cookie along with some unnecessary parameters.

via GIPHY

Sequel

March 2019

The marketing manager that I’ve worked with has already left and his replacer was launching a new website, trying carefully not to break anything in the process.

She called me up to see if I still have the technical documents I’ve previously shared with their Dev team. Lucky for her that I’m a very organized person. Documents were sent and peace was restored.

Notes

The meta-plot outline is based on “The Seven Basic Plots: Why We Tell Stories” by Christopher Booker

Originally published on my blog on Medium

2 Responses

  1. Does anyone have an idea how to fix case when cid is changed when we’re moving from “A” to “B” while cross-tracking is already setup (linker is on and _ga=” parameter is implemented in “B” url)?

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts