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)
})
AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. AngularJS's data binding and dependency injection eliminate much of the code you would otherwise have to write.
Angular uses TypeScript and has components as its main building blocks. It is component-based, whereas AngularJS uses directives. Angular's operation employs a hierarchy of components, while AngularJS has directives that allow code reusability. So, The AngularJS framework provides reusable components for its users.
The primary difference between AngularJS and ReactJS lies in the state of its management. AngularJS has data binding bundled in by default, whereas React is generally augmented by Redux to give unidirectional data flow and work with immutable data.
JavaScript has an extensive user interface that includes sliders and other features. On the other hand, AngularJS is a data-driven framework that's used to create web applications. JavaScript is a powerful and complex programming language. On the other hand, AngularJS is a simple and effective framework.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With