Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
})
like image 755
Omranic Avatar asked Aug 28 '14 07:08

Omranic


People also ask

What AngularJS used for?

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.

Is AngularJS vs Angular?

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.

What is AngularJS vs ReactJS?

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.

Which is better AngularJS or JavaScript?

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.


1 Answers

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.

like image 78
Omranic Avatar answered Sep 27 '22 22:09

Omranic