问题
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:
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.
回答2:
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.
回答3:
Another thing to consider with tracking in multiple accounts is that any events in the page will be sent to whichever account was set last in the _setAccount call. I spent months wondering why my events weren't showing up under my main account and then realized we had an extra set of tracking code appearing after the main tracking code with a call to _setAccount for the affiliate account. My event tracking code appeared to be working fine, but events never showed up in my account. Moving the affiliate code to before our main tracking code solved the problem.
来源:https://stackoverflow.com/questions/2651834/google-analytics-async-tracking-with-two-accounts