1.4.1 • Published 8 years ago
meanie-angular-analytics v1.4.1
meanie-angular-analytics
An Angular wrapper service for Google Analytics
Installation
You can install this package using npm
:
npm install meanie-angular-analytics --save
Include the script node_modules/meanie-angular-analytics/release/meanie-angular-analytics.js
in your build process, or add it via a <script>
tag to your index.html
:
<script src="node_modules/meanie-angular-analytics/release/meanie-angular-analytics.js"></script>
Add Analytics.Service
as a dependency for your app.
Usage
angular.module('App', [
'Analytics.Service'
])
.config(function($analyticsProvider, Config) {
$analyticsProvider.setEnabled(Config.ANALYTICS_ENABLED && Config.ANALYTICS_TRACKING_ID);
})
.run(function($rootScope, $analytics, Config) {
//Check if enabled
if ($analytics.isEnabled()) {
//Create site wide tracker
$analytics.create(Config.ANALYTICS_TRACKING_ID);
//On state changes, track page views
$rootScope.$on('$stateChangeSuccess', function() {
$analytics.track.pageview();
});
}
});
Issues & feature requests
Please report any bugs, issues, suggestions and feature requests in the meanie-angular-analytics issue tracker.
Contributing
Pull requests are welcome! If you would like to contribute to Meanie, please check out the Meanie contributing guidelines.
Credits
- Meanie logo designed by Quan-Lin Sim
License
(MIT License)
Copyright 2016-2017, Adam Reis