[英]Google analytics for localhost site
I've deployed website that is running on server on local network and I would like to track traffic with Google analytics. 我已经部署了在本地网络上的服务器上运行的网站,并且希望通过Google Analytics(分析)跟踪流量。
Following code, that was generated by google analytics, is placed in pages that I would like to track 以下代码(由Google Analytics(分析)生成)放置在我要跟踪的页面中
<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-XXXX-Y', { 'cookieDomain': 'none'});
ga('send', 'pageview');
</script>
This line of code was modified according to this topic . 这行代码已根据该主题进行了修改。
ga('create', 'UA-XXXX-Y', { 'cookieDomain': 'none'});
When I visit my admin page on Google analytics site it says under Status that Tracking is not installed . 当我访问Google Analytics(分析)网站上的管理页面时,在“ 状态 ”下显示“ 未安装跟踪” 。
Page was visited from several computers but it seems that page view info is not getting to Google servers. 页面是通过多台计算机访问的,但是页面查看信息似乎无法访问Google服务器。
Am I missing something? 我想念什么吗?
Another way around would be to add a FQDN to your local /etc/hosts
file, eg 另一种解决方法是将FQDN添加到本地
/etc/hosts
文件,例如
127.0.0.1 localhost.dev
Point your browser to http://localhost.dev/ instead. 将浏览器指向http://localhost.dev/ 。
At the end it seemed that inserted code was enough. 最后,似乎插入的代码就足够了。 It just required some time for google servers to get and process the information.
Google服务器仅需要一些时间来获取和处理信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.