Dual Google Analytics – Classic Analytics

Sometimes there are reasons to have two sets of Google Analytics on a page, or a website. For those occasions, here is the format for tracking for two Google Analytics Classic properties (not Univseral Analytics). Simply replace UA-######-A and UA-######-B with the two Google Classic Analytics property IDs.

Watch out for fancy single and double quotes, although they might look nice in the blog, they might stop the code from working! I just checked myself and it looks fine, but I may be using a different computer & browser combination than you. If your code does not work after copy and pasting it, make sure all of the quotes you copied are normal quotes and not fancy quotes.

<script type="text/javascript">
   var _gaq = _gaq || [];
   _gaq.push(
   ['_setAccount', 'UA-######-A'],
   ['_trackPageview'],
   ['b._setAccount', 'UA-######-B'],
   ['b._trackPageview']
   );
   (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   })();
</script>

Leave a Reply

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