谷歌分析代码不记录流量?

时间:2010-02-09 15:49:20

标签: javascript google-analytics

我客户网站的某个Google分析代码无效。

此代码有什么问题?

<script type='text/javascript'>
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);


document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));


</script>
<script type='text/javascript'>
try {
var pageTracker = _gat._getTracker(&quot;UA-8830811-1&quot;);


pageTracker._trackPageview();
} catch(err) {}</script>

1 个答案:

答案 0 :(得分:2)

问题是所有额外的实体编码(即&quot;等)。此外,一旦您使用正确的代码,它可能需要长达24小时才能开始显示数据,但通常在几个小时内它会显示绿色“√”以表示跟踪代码已正确安装。请改用:

<script type='text/javascript'>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type='text/javascript'>
try {
  var pageTracker = _gat._getTracker("UA-8830811-1");
  pageTracker._trackPageview();
} catch(err) {}
</script>​​