Javascript 为什么我的Google Analytics代码不跟踪所有域的数据?
我无法显示实际的网站和内容,因此我将网站改为random.com,将两个未被跟踪的网站改为example1和example2.com。主网站是example.com 这是一个包含GA跟踪代码的外部js文件。在example.com的head标签中,它还带有交叉跟踪部分。在var域[example1.com和example2.com]中,实际上没有通过谷歌分析得到跟踪 我没有访问外部js文件的权限。所以我想知道的是,它的书写方式是否有错误 我相信问题可能是三件事之一,或者我完全错了; 1.)示例1和示例2实际上位于网站内,因此子域不是不同的域 2.)或者它没有在整个阵列中运行。因为除example1.com和example2.com外,var域中的所有域都将数据推送到google analytics中 3.)或gaq.push([''u setAllowLinker',true]需要是gaq.push([''u setAllowLinker',[此处为域]true]Javascript 为什么我的Google Analytics代码不跟踪所有域的数据?,javascript,jquery,google-analytics,Javascript,Jquery,Google Analytics,我无法显示实际的网站和内容,因此我将网站改为random.com,将两个未被跟踪的网站改为example1和example2.com。主网站是example.com 这是一个包含GA跟踪代码的外部js文件。在example.com的head标签中,它还带有交叉跟踪部分。在var域[example1.com和example2.com]中,实际上没有通过谷歌分析得到跟踪 我没有访问外部js文件的权限。所以我想知道的是,它的书写方式是否有错误 我相信问题可能是三件事之一,或者我完全错了; 1.)示例1
编辑:删除了不相关的代码片段找到了解决方案。因此我需要忽略大部分代码
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setDomainName', 'example.com']);
_gaq.push(['_setLocalRemoteServerMode']);
_gaq.push(['_setLocalGifPath', 'http://www.example.com/__utm.gif']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();
这是唯一相关的部分。我需要删除
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setDomainName', 'example.com']);
_gaq.push(['_setLocalRemoteServerMode']);
_gaq.push(['_setLocalGifPath', 'http://www.example.com/__utm.gif']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();
在网站正常运行之后,这似乎是过时的经典GA代码。您能从代码示例中删除虚拟页面浏览代码以下载和外部链接吗?这似乎对问题并不重要,并且使阅读变得更加困难。
_gaq.push(['_setLocalRemoteServerMode']); //Pulls remote GA code for Urchin
_gaq.push(['_setLocalGifPath', 'http://www.example.com/__utm.gif']);