heroku - 谷歌分析在我的 heroku 应用上不起作用

标签 heroku google-analytics subdomain

我在 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/

相关文章:

php - 如何使用 Google Analytics PHP API 列出管理配置文件?

.htaccess - 如何停止.htaccess将子域重定向到主站点?

nginx - 子域是通过域名注册商还是网络服务器创建的?

login - 使用网站的子域登录用户

java - 未在目标中创建 Maven 依赖目录

node.js - 使用通过 heroku foreman 从 .env 文件加载的 RSA 私钥签署 JWT 时出错

python - Heroku 上找不到 CSS 文件 404

spring-boot - Spring Boot + Kotlin + Gradle - 错误 : Main method not found in class

regex - 用于匹配指定路径级别的页面 URI 的 Google Analytics 正则表达式

android - 谷歌分析安卓实时