Kinja Data Team

it's A/B test time, my dudes
it's A/B test time, my dudes

How I Made a Mess of Cross-Domain Tracking

Illustration for article titled How I Made a Mess of Cross-Domain Tracking

As I mentioned in a previous blog, we have turned on Google Analytics 'cross-domain tracking' across all Gawker sites and most of Kinja. However, the process took a lot longer than it should have, mostly due to my lack of understanding. I figured I'd share my poor choices with you in order to prevent you from dealing with the same mistakes.


We here at Gawker have our own internal tracking, which allows us to see how readers are moving across our site. However, that system is primarily geared towards understanding what gets readers to sign up and become contributors. (For a variety of reasons, primarily concern for our contributors' privacy, we don't want to make any of that available to third parties). So for general evaluation of our site, we use Google Analytics.


We checked the Google Analytics documentation about cross-domain tracking, but we weren't very happy with it. In short, Google asks us to give Google permission to 'link' our domains.

They give examples but basically the code should look like this:

ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});

ga('require', 'linker');

ga('linker:autoLink', ['', '', etc… ] );

Simple enough. However, there was concern internally that some of the parameters passed would either screw up our group chats or our cache system, depending on our implementation. We also weren't crazy about putting even more javascript on our pages.


So instead of using this method, we tried a workaround where we tracked activity via iframe. Basically, every time a reader visited a Deadspin page (or any other domain), a tiny page would be loaded inside with a tracking tag. This tag would then figure out which user was visiting, and pass the user's random tracking number to the parent (Deadspin) page, which would then pass that information to Google Analytics. So if I went from Deadspin to Jezebel, Google Analytics would recognize that the same person visited both pages.

When we implemented it, we saw that readers were de-duplicated, like we wanted. However, we ran into a big issue: even though we now knew that the same person might be visiting both Jezebel and Deadspin, we weren't stitching together those visits into the same session. Instead, our numbers were telling us that each reader was leaving the site and revisiting it, sometimes dozens of times in a day.


It turns out that I totally forgot to account for session tracking, and there's really no way to pass session info across domain without reading the session info directly from the cookie. But that's a whole other ball of wax with tons of edge cases to account for.

In the end, we implemented tracking the way Google said we should at the start. This did require coding around some of our existing group-chat code (we had a name-collision with the history.js library which required tackling some technical debt.


Fortunately, everything seems to be set up and working now. The lesson: I'm probably better off changing our site than depending on extended use of someone else's software.

[photo credit]

Share This Story

Get our newsletter