Angularjs 和 Google Analytics 集成

标签 angularjs google-analytics

我正在使用 AngularJS UI Router 和 revolunet/angular-google-analytics https://github.com/revolunet/angular-google-analytics

这是我的配置:

.config(function(AnalyticsProvider) {
        // initial configuration
        AnalyticsProvider.setAccount('UA-XXXXXXX-X');

        // track all routes/states (or not)
        AnalyticsProvider.trackPages(true);

        // Use analytics.js instead of ga.js
        AnalyticsProvider.useAnalytics(true);

        // change page event name
        AnalyticsProvider.setPageEvent('$stateChangeSuccess');
}))

现在还有其他步骤需要完成吗?我没有修改任何状态/ Controller 来包含任何分析代码,还需要什么吗?那么下面的评论是什么意思呢?我想启用“trackPages”就足够了,对吗?

.run(function(Analytics) {
  // In case you are relying on automatic page tracking, you need to inject Analytics
  // at least once in your application (for example in the main run() block)
})

最佳答案

来自@revolunet的官方回复 https://github.com/revolunet/angular-google-analytics/issues/35

You can check if it works in the chrome network console. check calls to google. (via an image i guess)

About the Analytics you need to inject it manually at least once somewhere in your app. (the run block is the good place) so it can be instantiated by angular.

关于Angularjs 和 Google Analytics 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25542859/

相关文章:

ios - 使Box iOS SDK WebAPI和Google Analytics(分析)iOS SDK 2.0beta3协同工作

angularjs - 在 Angular 1.5 中从父组件调用子组件函数

javascript - FS.Store.GridFS 由变换创建 : false

java - Flow.js和Java Servlet上传文件0字节

javascript - 带有反应的谷歌分析不起作用

ios - 移动广告网络如何在不需要修改广告应用程序的情况下跟踪应用程序安装?

javascript - AngularJS 根据日期检索 JSON 记录

angularjs - Uncaught Error : [$injector:unpr] Unknown provider: $cookiesProvider <- $cookies <- YourHttpInterceptor <- $http <- ng1UIRouter

google-analytics - 如何使用ZendGData Analytics获取所有配置文件ID?

javascript - 谷歌分析嵌入 api 取消授权