简体   繁体   English

Google Analytics(分析):未安装跟踪代码

[英]Google Analytics: Tracking code not installed

I was contacted for a problem in the site I have developed. 在我开发的网站上遇到问题时,与我联系。 They addressed to me the problem that this site was not getting any reports of page visits and etc. 他们向我解决了这个站点没有任何页面访问等报告的问题。

I went to Google Analytics to check the JS code but it was the same code in the site. 我去了Google Analytics(分析)检查JS代码,但它与站点中的代码相同。 But I noticed an error message above, "Tracking code not installed." 但是我注意到上面的错误消息“未安装跟踪代码”。 and "No hits." 和“没有点击”。

I googled for answers and I found one which tells people to remove www in the default URL of Property settings. 我用谷歌搜索了答案,发现其中一个告诉人们在“属性”设置的默认URL中删除www I didn't risk removing it as it may not access the site anymore. 我没有删除它的风险,因为它可能不再访问该网站。

I checked other sites' Google Analytics registered in that email, they were working fine. 我检查了在该电子邮件中注册的其他网站的Google Analytics(分析),它们工作正常。 I need your help to fix this. 我需要您的帮助来解决此问题。

Please see the JS code below which I pasted in the header area of the site, Wordpress site by the way. 顺便说一下,请参阅下面的JS代码,我将其粘贴到网站的标题区域(Wordpress网站)中。

<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-XXXXXXXX-X', 'auto');
   ga('send', 'pageview');

</script>

The script shown is for Universal Analytics . 显示的脚本适用于Universal Analytics If the property has not been upgraded, you need to use the "legacy" script : 如果该属性尚未升级,则需要使用“旧版”脚本

<script>   
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _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>

You can continue using this version even after you upgrade to Universal Analytics, but this code doesn't report the same data, so you lose a bit of information you could be leveraging. 即使升级到Universal Analytics,您也可以继续使用此版本,但是此代码不会报告相同的数据,因此您会丢失一些可以利用的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM