我正在使用 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/