Google Analytics - Asynchronous Tracking with Two Accounts

I am currently testing a new GAs asynchronous 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 noticed that they present inconsistent results. Now we are not talking about the huge differences here, only 1-2 times a day. However, this site is tiny, and 1 or 2 visits are equated to a 15% difference in numbers. Now the final site has a lot more traffic, but my problems;

  • Will this scale mismatch with traffic?
  • Assuming no, is a small change in the recorded statistics an accepted norm?
+4
source share
3 answers

You can avoid 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 save the cookies separately.

Note. I use this setting to track events in the second profile to maintain the accuracy of the failure rates. The second profile tracking code is only used on my blog, so it is not a complete profile.

+8
source

Are they from different accounts?

If so, check the statement made on the GA website

Multiple Analytics Accounts for a given Page Some users want to track the same page or set of pages in multiple Analytical accounts. Analytics designed to work effectively with a single account for a website relationship. If you have multiple tracking accounts of the same network property (such as a page or page sets), both accounts will read and set the same set of cookies. This configured is usually not recommended.

+2
source

Another thing to consider when tracking across multiple accounts is that any events on the page will be dispatched depending on which account was last set in the _setAccount call. For several months, I thought about why my events did not appear under my main account, and then realized that we have an additional set of tracking code that appears after the main tracking code, calling _setAccount for the partner account. My event tracking code seems to be working fine, but events have never appeared in my account. Moving affiliate code before our core tracking code resolved the issue.

0
source

Source: https://habr.com/ru/post/1307122/


All Articles