views:

392

answers:

2

I'm currently testing GAs new async code snippet using two different tracking codes on the same page;

_gaq.push(
    ['_setAccount', 'UA-XXXXXXXX-1'],
    ['_trackPageview'],
    ['b._setAccount', 'UA-XXXXXXXX-2'],
    ['b._trackPageview'] 
);

Although both codes work, I've noticed that they present inconsistent results. Now, we aren't talking huge differences here, only 1 or 2 visits / day every now and then. However, this site is tiny and 1 or 2 visits equates to a 15% difference in figures. Now, the final site has much more traffic, but my concerns are;

  • will this inconsistancy scale with traffic?
  • assuming not, is a slight variation in recorded stats an accepted norm?
+1  A: 

Are the from different accounts ?

If so check follow statement from GA website

Multiple Analytics Accounts on a Given Page Some users want to track the same page or set of pages in multiple Analytics Accounts. Analytics is designed to work effectively with a single account-to-web-property relationship. If you have multiple accounts tracking the same web property (e.g. page or sets of pages), both accounts will read from and set the same set of cookies. This set up is generally not recommended.

Ivo
That doesn't really answer either of my questions at all, and I think is only relevant to the old tracking code... I should point out that the js I'm using comes from Google's own code examples; http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html#MultipleCommands
MatW
Well the problem that I had with two accounts was that the visit count between them was different. If the codes are from the same account, then you dont have the same problem as I had
Ivo
Ivo is right. Using multiple trackers (in sync or async) will result in one tracker overwriting the cookie values of the other. How badly this skews your data is entirely dependent on how you use those trackers.
Brian
A: 

You can avoid the conflicting cookies by setting a different domain for google analytics.

<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-NNNN-1']);

// primary profile
_gaq.push(['_setDomainName', 'www.domain.com']);
_gaq.push(['_trackPageview']);
_gaq.push(function() {
    // create the second async tracker
    _gaq._createAsyncTracker('UA-NNNN-2', 'blogTracker');
});

// secondary profile (this is the default domain setup if not specified) 
_gaq.push(['blogTracker._setDomainName', 'domain.com']);
_gaq.push(['blogTracker._trackPageview']);  
//]]>
</script>

This will keep the cookies separate.

Note: I am using this setup to track events in a second profile to keep my bounce rate numbers accurate. The second profile tracking code is only used on my blog, thus, is not a complete profile on purpose.

Bryan Pieper