Angularjs & Google Analytics Integration

I'm using AngularJS UI Router, and revolunet/angular-google-analytics https://github.com/revolunet/angular-google-analytics

Here it is my config:

.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');
}))

Now is there any other steps to complete? I have NOT modified any states/controllers to include any analytics code, is there anything else required? And what does the following comment means? I guess enabling 'trackPages' is enough, am I right?

.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)
})

Official reply from @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.

链接地址: http://www.djcxy.com/p/22464.html

上一篇: Spring启动JPA数据库选择

下一篇: Angularjs和Google Analytics集成