Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dylanvalade/b920792660db558c8157 to your computer and use it in GitHub Desktop.
Save dylanvalade/b920792660db558c8157 to your computer and use it in GitHub Desktop.
Google Analytics Cross Domain Tracking with Linker Plugin
<!-- Cross Domain Analytics Provided by Google Support -->
<!--
1. Log into Analytics and go to Admin > (Property Column) Tracking Info > Referral Exclusion List
2. Add each linked domain to the list, which says that these are not referrals - they are continutations of the same visit
-->
<!-- Primary Domain Tracking Script (e.g. hayowentha.org) -->
<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-7419076-1', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['hayowentha.org', 'ymcahayowentha.campbrainregistration.com']);
ga('send', 'pageview');
</script>
<!-- Secondary Domain Tracking Script (e.g. ymcahayowentha.campbrainregistration.com) -->
<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-13057929-7', 'auto', {'allowLinker': true});
ga('send', 'pageview');
ga('newTracker.send', 'pageview');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment