1

我的目标是在每个网站上设置 2 个跟踪:一个特定于网站,第二个用于汇总属于网络的网站的数据。

here is the code i implemented :

// UA-XXXXXXXX-1 = Global tracking
// UA-XXXXXXXX-2 = Specific tracking

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(["_setCustomVar", 1, "Type", "Value_Type", 1]);
_gaq.push(['_trackPageview']);
var _gaq2 = _gaq2 || [];
_gaq2.push(['_setAccount', 'UA-XXXXXXXX-2']);
_gaq2.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);
})();

This code is not working : specific tracking is not working. Any idea why ?
Thanks in advance
4

1 回答 1

3

您的代码应该如下所示:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(["_setCustomVar", 1, "Type", "Value_Type", 1]);
_gaq.push(['_trackPageview']);

_gaq.push(['SPECIFIC._setAccount', 'UA-XXXXXXXX-2']);
_gaq.push(['SPECIFIC._trackPageview']);
于 2013-03-14T12:33:38.660 回答