我希望跟踪一个子域,其中有两个顶级域指向它。例如:
my.test.com my.test.org
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXXX-1']);
_gaq.push(['_setDomainName', 'test.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>我已经找到了这段代码以及关于多个子域的过滤器的信息,但我不知道如何处理两个顶级域。该示例将_setDomainName显示为特定的顶级域。我将如何使这个工作与两个顶级域名?
发布于 2013-12-17 08:18:59
您想要的是设置跨域跟踪。您目前“缺少”的实际上是通过_link调用将两个域连接在一起。
正如在https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite#multipleDomains上详细介绍的那样,您需要在指向两个域之间的链接的任何链接中添加一个参数。
这实际上是允许Google在顶级域之间复制cookie数据。
my.test.com上的链接应该_link到my.test.org,反之亦然。
示例:<a href="http://my.test.org/" onclick="_gaq.push(['_link','http://my.test.org/']); return false;">Anchortext to my.test.org</a>
如果post用于传输访问者,您也可以在上面的URL上找到说明。
https://stackoverflow.com/questions/20623863
复制相似问题