GithubHelp home page GithubHelp logo

angulartics2's Introduction

angulartics2

NPM version NPM downloads devDependency Status Build Status

MIT license Gitter Chat

Vendor-agnostic analytics for Angular2 applications. angulartics.github.io

Install

npm install angulartics2 --save

If you use SystemJS to load your files, you might have to update your config with this if you don't use defaultJSExtensions: true:

System.config({
    packages: {
        "/angulartics2": {"defaultExtension": "js"}
    }
});

Minimal setup

for Google Analytics

Add the full tracking code from Google Tag Manager to the beginning of your body tag.

Changes in the Google Analytics snippet

The snippet code provided by Google Analytics does an automatic pageview hit, but this is already done by Angulartics (unless you disable it) so make sure to delete the tracking line:

      ...
      ga('create', 'UA-XXXXXXXX-X', 'none'); // 'none' while you are working on localhost
      ga('send', 'pageview');  // DELETE THIS LINE!
    </script>

Include it in your application

import {Angulartics2, Angulartics2On} from 'angulartics2';
import {Angulartics2GoogleAnalytics} from 'angulartics2/providers/angulartics2-google-analytics';

bootstrap(AppComponent, [
    Angulartics2
]);


import {Component, View, Injectable} from 'angular2/angular2';

@Injectable()
@Component({
    selector: 'app',
    providers: [Angulartics2GoogleAnalytics]
})
@View({
    template: `<div [angulartics2On]="'click'" [angularticsEvent]="'InitiateSearch'" [angularticsCategory]="'Search'"></div>`,
    directives: [Angulartics2On]
})
export class AppComponent {
    constructor(angulartics2: Angulartics2, angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics) {
    }
}

for other providers

Browse the website for detailed instructions.

Supported providers

  • Google Analytics
  • Kissmetrics
  • Mixpanel
  • Segment

If there's no Angulartics2 plugin for your analytics vendor of choice, please feel free to write yours and PR' it!

What else?

See more docs and samples at http://angulartics.github.io.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.