2

我正在尝试在我的网站上设置谷歌分析但是,它不起作用。例如,在跟踪信息中显示:状态:未安装跟踪。我已经在我的标签之前将他们提供的代码添加到我的 header.php 文件中</head>

我添加的代码是:

<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-41420598-1', 'example.com');
  ga('send', 'pageview');

</script>

我在页内分析部分看到我的网站,但收到一条错误消息:

Your site doesn't load ga.js from Google. If you host the Google tracking code on your  
own servers, it isn't updated automatically and can miss important changes.
We didn't find a tracking snippet on your site. In-Page Analytics cannot load. Please  
make sure you have tracking installed correctly. If your snippet is included in a    
separate JavaScript file, you'll have to manually check it is being loaded correctly.

有人可以帮我弄这个吗?我该如何解决这个问题?

4

1 回答 1

3

您确定您拥有正确的分析代码吗?我的不一样,见:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXX-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>

(此代码具有谷歌希望看到的 ga.js)确保再次检查代码。登录到分析 > 点击管理员(在右上角) > 点击跟踪信息选项卡 > 获取底部的代码

于 2013-06-04T04:41:07.610 回答