1
可能重复:
google analytics - multiple trackers on one page (cookie conflict)两个谷歌分析每页占
我周围中搜索关于这个问题的网络,但无法找到我要找的答案。
我开发了一个博客,有一些特殊功能。每个用户在注册时都会获得他们自己的子域名。
一切都是免费的,但与广告。我目前使用谷歌分析来跟踪访客和浏览量的总数。
我开发了一个小型计数器,以便每个用户都可以查看他们有多少访问者和浏览量,但对于更详细的信息,他们需要使用他们自己的“谷歌分析”,或者他们想要使用什么。
所以。我现在使用的代码:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx1-1']);
_gaq.push(['_setDomainName', 'sub.domain.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
我不知道每个用户使用什么类型的分析服务的,我让他们在HEAD中插入自己的代码。 因此,如果他们使用谷歌分析,我们在谷歌分析的两个帐户会得到正确的访问者数量?然后,该代码将是:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx1-1']);
_gaq.push(['_setDomainName', 'sub.domain.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx2-1']);
_gaq.push(['_setDomainName', 'sub.domain.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
还是我必须要做得像:
_gaq.push(
['_setAccount', 'UA-XXXXXXXX-1'],
['_trackPageview'],
['b._setAccount', 'UA-XXXXXXXX-2'],
['b._trackPageview']
);
如果双方跟踪器内相同。 ??
谢谢!
后一种方法是我已知的方法之一,因为我在一个网站上使用。 – Sandeep