我在 heroku 平台上运行了一个 python 网络应用程序,
使用 heroku 子域,如:example.herokuapp.com
我添加 google analytics
js代码到我的页面:
(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', 'herokuapp.com');
ga('send', 'pageview');
我已经插入这个脚本超过 12 个小时,但是当我进入我的 ga 帐户管理面板时,它告诉我:
The Google Analytics tracking code has not been detected on your website's home page. For Analytics to function, you or your web administrator must add the code to each page of your website.
但是,我仍然可以在报告面板上看到一些 PV
ga 工作还是不工作?我怎么解决这个问题?如果我使用顶级域可以解决这个问题吗?
最佳答案
关于您的两件事 ga.create()
称呼:
1)第三个参数(在你的例子中是“herokuapp.com
”)应该是一个 Javascript 对象,而不是一个普通的字符串。你真的是说 {'cookieDomain': 'herokuapp.com'}
?
2) 如果你做了... 那么它应该是 example.herokuapp.com
-- 您不能在所有 herokuapp.com
上设置 cookie .
关于heroku - 谷歌分析在我的 heroku 应用上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18222631/