@meanie/angular-analytics

2.0.1 • Public • Published

@meanie/angular-analytics

npm version node dependencies github issues codacy

An Angular wrapper service for Google Analytics

Meanie

Installation

You can install this package using yarn or npm:

#yarn
yarn add @meanie/angular-analytics

#npm
npm install @meanie/angular-analytics --save

Include the script node_modules/@meanie/angular-analytics/release/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/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.

Sponsor

This package has been kindly sponsored by Hello Club, an all in one club and membership management solution complete with booking system, automated membership renewals, online payments and integrated access and light control. Check us out if you happen to belong to any kind of club or if you know someone who helps run a club!

License

(MIT License)

Copyright 2016-2020, Adam Reis

Package Sidebar

Install

npm i @meanie/angular-analytics

Weekly Downloads

0

Version

2.0.1

License

MIT

Unpacked Size

33.7 kB

Total Files

13

Last publish

Collaborators

  • adamreisnz