mdh
mdh

Reputation: 418

Cross Domain Tracking in Google Universal Analytics with Javascript Links

So I have a scenario where I am constantly getting a good number of self-referral traffic to my website. I investigated it further and believe it to be a case of an issue with my cross domain tracking (as I use a 3rd party shopping cart).

What I can't seem to figure out is what I have wrong and why it isn't working. My specific scenario looks like the following

MainSite.com Analytics Code

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX210-1', 'auto', {'allowLinker': true});
  ga('require', 'linker');
  ga('linker:autoLink', ['mainsite.com','checkoutsite.com'], true, true); 
  ga('require', 'displayfeatures');
  ga('send', 'pageview');
</script>

CheckoutSite.com Analytics Code

<script type="text/javascript">   
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-XXXXX210-1', 'auto', {
      'allowLinker': true
    });
    ga('require', 'ec');
</script>

As for the setup options:

The links to the checkout cart are Javascript based which result in a iframe popover. They look like the follwing:

<a class="eztixKioskLink tourTemplateId_XXXX" href="javascript:void(0);">
  <img alt="" src="http://www.mainsite.com/buy.png" />
</a>

However, I still appear to be getting self-referrals and am completely unable to figure out why. Is there something wrong with my code or my setup? Is there something else I should be looking for?

Any help would be hugely appreciated!

Upvotes: 0

Views: 431

Answers (1)

TomFuertes
TomFuertes

Reputation: 7270

You should be good code wise. You can also exclude those domains as referrers:

https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#selfreferrals

As you go through the flow yourself do you see #_ga hash's being appended? If not you'll need to reverse engineer the javascript link clicks as the outgoing clicks aren't getting decorated:

https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#linkerparam

Upvotes: 2

Related Questions