【问题标题】:Why isnt my Google Analytics code tracking data across all domains?为什么我的 Google Analytics(分析)代码没有跨所有域跟踪数据?
【发布时间】:2015-09-10 21:08:06
【问题描述】:
  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);
  })();

我无法显示实际的网站和内容,所以我将网站更改为 random.com,两个未跟踪的网站分别为 example1 和 example2.com 主网站是 example.com

这是一个包含 GA 跟踪代码的外部 js 文件。那是在 example.com 的 head 标签中它也有交叉跟踪部分。在 var 域 [example1.com 和 example2.com] 中实际上并没有通过谷歌分析进行跟踪。

我无权访问外部 js 文件。所以我想知道它的编写方式是否有错误。

我相信问题可能是三件事之一,或者我完全错了; 1.) example1 和 example2 实际上在网站内,因此子域不是不同的域。

2.) 或者它没有贯穿整个阵列。因为 var 域中的所有域都将数据推送到谷歌分析中,除了 example1.com 和 example2.com。

3.) 或者 gaq.push(['_setAllowLinker', true] 需要是 gaq.push(['_setAllowLinker', [这里是域] true]

编辑:删除不相关的代码

【问题讨论】:

  • 您能否从您的代码示例中修剪虚拟网页浏览代码以进行下载和外部链接?这对这个问题似乎并不重要,并且使它更难阅读。

标签: javascript jquery google-analytics


【解决方案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);
  })();

这是唯一相关的部分。我需要删除

_gaq.push(['_setLocalRemoteServerMode']); //Pulls remote GA code for Urchin 
 _gaq.push(['_setLocalGifPath', 'http://www.example.com/__utm.gif']); 

在网站运行良好之后,这似乎是过时的经典 GA 代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-06
    • 1970-01-01
    • 2014-02-18
    • 2023-03-29
    • 2015-01-31
    • 2012-03-21
    • 2012-02-14
    • 1970-01-01
    相关资源
    最近更新 更多