我最近开始使用https://support.google.com/analytics/answer/1033876?hl=en-GB&ref_topic=2772342中概述的多个域跟踪代码设置,并尝试将其与现有域属性现有GA跟踪器代码混合使用。
但是当我查看多域跟踪器网络媒体资源的跟踪器状态时,多域跟踪代码没有显示任何数据或被提取?
我对这个问题感到茫然。使用适用于Chrome的GA调试器扩展程序会显示2个GA跟踪器输出相同的数据,包括相同的帐户UA-XXXXXXX ID 。
背景
我在同一个domain1.comm上有3个网络媒体资源,2个使用子域名。所以3个网页属性都是
每个媒体资源都拥有自己的GA网络媒体资源和独特的跟踪代码,可用于单独跟踪。就像这样
<script type="text/javascript">
var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-XXXXXXX-1']);
_gaq.push(['_setDomainName','domain1.com']);
_gaq.push(['_setSiteSpeedSampleRate',100]);
_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>
现在,我想为3个网络媒体资源中的每一个添加第2个跟踪器,以便在所有3个网络媒体资源中进行多个网络跟踪,因此请按以下步骤进行设置
for domain1.com
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXY-2', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['forum.domain1.com, 'blog.domain1.com'] );
ga('send', 'pageview');
</script>
for forum.domain1.com
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXY-2', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['domain1.com, 'blog.domain1.com'] );
ga('send', 'pageview');
</script>
for blog.domain1.com
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXY-2', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['domain1.com, 'forum.domain1.com'] );
ga('send', 'pageview');
</script>
添加SiteSpeedSampleRate
另外,要将SiteSpeedSampleRate添加到多个域跟踪器代码,这是正确的吗?
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
_gaq.push(['_setSiteSpeedSampleRate', 100]);
_gaq.push(['_trackPageview']);
ga('create', 'UA-XXXXXXY-2', 'domain1.com');
ga('send', 'pageview');
</script>
答案 0 :(得分:2)
由于您只使用不同的子域名在同一个域中,因此您无需使用自动链接。只需将cookie域设置为最高级别(domain1.com)。此外,如果您在同一页面上运行多个跟踪器,则需要为它们提供自己的命名空间。
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
/* Assuming the existing properties are migrated to Universal Aanlytics - which they should be */
ga('create', 'UA-XXXXXXX-1', 'domain1.com');
ga('send', 'pageview');
/* Note the inclusion of the name property */
ga('create', 'UA-XXXXXXY-2', 'domain1.com', {'name': 'multi'});
ga('multi.send', 'pageview');