谷歌分析 - 一个页面上的多个跟踪器(传统和异步) [英] google analytics - multiple trackers on one page (traditional and asynchronous)

查看:145
本文介绍了谷歌分析 - 一个页面上的多个跟踪器(传统和异步)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个嵌入其他人网站的小部件。我正在使用Google Analytics(分析)来跟踪所有在嵌入网站上访问我的脚本的所有实例的人员。 我了解新的异步跟踪代码解决了这个问题,这样就不会干扰这些网站的'拥有Google Analytics帐户。然而,如果我的分析跟踪代码使用新的异步跟踪器,并且嵌入网站正在使用旧版(传统)跟踪代码,那该怎么办?这两个代码块之间会有什么干扰?

我的跟踪代码:

 <脚本> 
...
_gaq.push(
['myTracker._setAccount','UA-XXXXX-2'],//命名跟踪器'myTracker'不同于任何默认跟踪器已经定义了
['myTracker._trackPageview']
);
...
< / script>

嵌入网站代码:

 < script type =text / javascript> 
尝试{
var pageTracker = _gat._getTracker(UA-xxxxxx-1);
pageTracker._trackPageview();
} catch(err){}< / script>

pageTracker和myTracker可以共存并将分析信息注册到他们自己的独立帐户吗?

解决方案

据官方的建议,这不是一个支持的方案:


    < li> /www.google.com/support/forum/p/Google+Analytics/thread?tid=3490dc16fec867c5&hl=zh_CN


还有一些缺陷:



当你说嵌入到人们的网站中时,如果你的意思是你的小部件存在于iframe中,那么你不必担心。 / p>

如果代码在页面中松散,那么你应该尝试使用不同的变量名称到默认的变量名称,以免冲突。这意味着将var _gaq = ...更改为其他内容,然后在整个代码中对其进行重命名。





如果它被插入到多个域中,您将需要设置多个GA帐户并为每个用户使用不同的帐号。



如果这是针对您拥有的客户那么您可以考虑简单地向报告中添加额外的用户,以便您可以查看一个中央帐户中的所有帐户: href =http://www.google.com/support/analytics/bin/answer.py?hl=zh_CN&answer=55500&utm_id=ad =nofollow> http://www.google。 COM /支持/分析/的bin / answer.py HL = EN_US&安培;答案= 55500&安培;的utm_id =广告

I'm writing a widget that will be embedded in other people's websites. I'm using Google Analytics to track all the people that visit all instances of my script on the embedding websites. I understand that the new asynchronous tracking code resolves this problem so that there's no interference with those websites' own Google Analytics accounts.

However, what if my analytics tracking code uses the new asynchronous tracker, and the embedding website is using the legacy (traditional) tracking code? Would there be any interference between these two blocks of code?

My tracker code:

<script>
...
_gaq.push(
  ['myTracker._setAccount', 'UA-XXXXX-2'], // naming the tracker 'myTracker' to be different from any default tracker already defined
  ['myTracker._trackPageview']
);
...
</script>

Embedding website's code:

<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-1");
pageTracker._trackPageview();
} catch(err) {}</script>

Can pageTracker and myTracker co-exist and register analytics information to their own separate accounts?

解决方案

As far as official advice goes this is not a supported scenario:

And there are pitfalls:

When you say embedded in peoples websites if you mean that your widget lives inside an iframe then you dont need to worry.

If the code is going to be loose in the page then you should try to use a different variable name to the default one so it doesn't clash. This means change the var _gaq = ... to something else and then renaming it throughout your code.

I'm not entirely clear on your setup but if it is being inserted into many domains you are going to need to set up multiple GA accounts and use different account numbers per user.

If this is for clients that you have access to then you might consider simply adding an extra user to the report so that you can view all the accounts from one central account:

这篇关于谷歌分析 - 一个页面上的多个跟踪器(传统和异步)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆