[英]Track domain from subdomain (Google analytics)
我已经在域的子域中添加了此代码以跟踪某些页面,但我不知道为什么它不起作用。
我想提到的是,跟踪的页面在域上,而不在子域上。
<script type="text/javascript">
window.onload = function () {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-15318659-1']);
_gaq.push(['_setDomainName', 'savoyhotel.ro']);
var hdStep = parseInt(document.getElementById('hdStep').value);
switch (hdStep) {
case 1: { _gaq.push(['_trackPageview', '/alege-data']); if(document.location.hash == '#test-lucian-20130401') { alert('alege-data') } break; }
case 2: { _gaq.push(['_trackPageview', '/alege-camera']); if(document.location.hash == '#test-lucian-20130401') { alert('alege-camera') } break; }
case 3: { _gaq.push(['_trackPageview', '/date-personale']); if(document.location.hash == '#test-lucian-20130401') { alert('date-personale') } break; }
case 4: { _gaq.push(['_trackPageview', '/finalizare-fara-garantare']); if(document.location.hash == '#test-lucian-20130401') { alert('finalizare-fara-garantare') } break; }
case 5: { _gaq.push(['_trackPageview', '/finalizare']); if(document.location.hash == '#test-lucian-20130401') { alert('finalizare') } break; }
}
(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>
有人知道吗
您将需要跟踪您的基本域“ .savoyhotel.ro”(请注意额外的注意。在开始时),并且在内部分析中设置规则以过滤域和子域。 例如,在我们的某些站点上,我们在分析中具有过滤器,使我们可以使用单个分析标记来显示主域,子域和组合域的流量。
在iPad上,现在很难精打细算,但是如果没有人发布更详细的答案,那么当我回到家里时,会在几个小时内发布以下步骤
但这基本上可以归结为这里所说的内容在Google Analytics(分析)中设置子域包括过滤器
更新:
1,切换回使用常规分析代码,然后添加。 到域的最前面
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount' , 'UA-15318659-1']);
_gaq.push(['_setDomainName', '.savoyhotel.ro']);
_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>
现在,如果您喜欢创建一个小的包装函数,以方便您在需要时从代码中调用trackPageView
function trackPageView(page) {
window._gaq = window._gaq || [];
window._gaq.push(['_trackPageview', page]);
}
这是您唯一需要跟踪主域+子域中的所有综合浏览量的事情
现在,如果您愿意,可以将分析中的配置文件设置为只有一个配置文件,该配置文件仅显示您主域中的分析,而另一个显示您的子域中的配置文件,这就是Google Analytics(分析)中设置子域包含过滤器的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.