使用两个帐户进行异步跟踪

使用两个帐户进行异步跟踪

本文介绍了Google Analytics(分析) - 使用两个帐户进行异步跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在同一页面上使用两个不同的跟踪代码测试GAs新的异步代码片段;

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

虽然这两个代码都可以工作,但我注意到他们提出了不一致的结果。现在,我们不是在这里谈论巨大的差异,偶尔每隔一两次访问一次。然而,这个网站是微小的,1或2次访问相当于15%的数字差异。现在,最终的网站有更多的流量,但我的担忧是;


  • 这种不一致性会随着流量而扩大吗? 假设没有,假设没有,记录统计信息有轻微变化吗?
  • 方案

您可以通过为Google Analytics(分析)设置不同的域来避免相互冲突的Cookie。

 <脚本类型= 文本/ JavaScript的 > 
//<![CDATA [
var _gaq = _gaq || [];
_gaq.push(['_ setAccount','UA-NNNN-1']);

//主简档
_gaq.push(['_ setDomainName','www.domain.com']);
_gaq.push(['_ trackPageview']);
_gaq.push(function(){
//创建第二个异步跟踪器
_gaq._createAsyncTracker('UA-NNNN-2','blogTracker');
}) ;
$ b $ //辅助配置文件(如果未指定,这是默认的域设置)
_gaq.push(['blogTracker._setDomainName','domain.com']);
_gaq.push(['blogTracker._trackPageview']);
//]]>
< / script>

这样可以保持cookies不同。



注意:我正在使用此设置跟踪第二个配置文件中的事件,以确保跳出率数据的准确性。第二个配置文件跟踪代码仅用于我的博客,因此,目的不是完整的配置文件。

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?

解决方案

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.

这篇关于Google Analytics(分析) - 使用两个帐户进行异步跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 21:31