August 12, 2010
Google Analytics: Two Primary Tracking Accounts

Ever wonder how to have two separate Google Analytics accounts track the same primary domain? With a little tweaking, the code works!

We now have two GA accounts that are both set as the primary account on one domain. Both accounts are pulling analytics data as if they were the primary. We had to do a little custom tweaking to GA’s Asynchronous Tracking code.
Google provided a little help:
http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html
The resulting code:
<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-1966692-10'],
['_trackPageview'],
['b._setAccount', 'UA-16375401-1'],
['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>

Here we see how to have two GA accounts both set as the primary account on one domain. Both accounts are pulling analytics data as if they were the primary. We had to do a little custom tweaking to GA’s Asynchronous Tracking code.

Google provided a little help:

http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html

The resulting code:

<script type=”text/javascript”>

var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-1966692-10'],
['_trackPageview'],
['b._setAccount', 'UA-16375401-1'],
['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>