我的目标是在每个网站上设置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
答案 0 :(得分: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']);