【问题标题】:Google Analytics Not Tracking Correctly谷歌分析没有正确跟踪
【发布时间】:2012-10-09 20:43:26
【问题描述】:

我最近将我网站的一个 Google Analytics(分析)跟踪代码更新为最新(异步)版本。自从这样做以来,它就没有正确跟踪链接。所有链接都是作为引荐传入的,而不是我在传入链接中指定的 Analytics utm 参数(即关键字、来源、活动等)。

我还在网站上添加了 Google 自定义搜索引擎。以下是页面上结束 head 标记之前的代码示例(使用假帐号等)(分析和 CSE 代码):

 <script type="text/javascript">

   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-XXXXXXXXX-X']);
   _gaq.push(['_setDomainName', 'sitedomain.com']);
   _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>
 <script type="text/javascript">
   (function() {
     var cx = '0000000000000000:aksjfhkjw';
     var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
     gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
         '//www.google.com/cse/cse.js?cx=' + cx;
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
   })();
 </script>

上面有什么问题吗?例如,既然 cse 在同一页面上,我是否应该以任何方式修改常规 Analytics 脚本?

感谢您的帮助!

【问题讨论】:

    标签: google-analytics analytics google-custom-search


    【解决方案1】:

    我认为您的代码看起来不对。

    这是我用于 Google Analytics 代码的内容:

        <script type="text/javascript">
    
          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'UA-xxxxxxxxxx']);
          _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>
    

    我没有在我们的域上进行站点搜索,但这当然足以将数据导入 GA。您的_gaq.push(['_setDomainName', 'sitedomain.com']); 可能被视为推荐人。试试看,然后告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-06
      • 2013-09-18
      相关资源
      最近更新 更多