Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics - async tracking with two accounts

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?
like image 328
Mathew Avatar asked Dec 28 '22 19:12

Mathew


2 Answers

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.

like image 194
Bryan Pieper Avatar answered Dec 31 '22 08:12

Bryan Pieper


Are they 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.

like image 39
Ivo Avatar answered Dec 31 '22 07:12

Ivo