google analytics - multiple trackers on one page (cookie conflict)

Now made easy with the new asynchronous tracking code. :)

https://developers.google.com/analytics/devguides/collection/gajs/#MultipleCommands


You can install multiple instances of the Google Analytics tracking code on your web pages to send data to multiple properties in your account. https://support.google.com/analytics/answer/1032400?hl=en

Or you can get creative and do the following per Google's instructions. https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#multipletrackers

<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-XXXX-Y', 'auto');
  ga('create', 'UA-XXXX-Y', 'auto', {'name': 'newTracker'});
  ga('send', 'pageview');
  ga('newTracker.send', 'pageview');

</script>