Powerful Analytics tool for Angular applications: Angulartics2

We’ve created the open source library Angulartics2 to plug into your Angular single page app (SPA) for analytics integration. It allows you to do event tracking and it is ready to integrate with Google Analytics, Google Tag Manager, Kissmetrics, Mixpanel, Piwik, Segment, Baidu Analytics and Facebook Pixel.



Most analytics providers do not automatically track the browser’s navigation history, making it difficult to track Single Page Applications (SPAs) like Angular applications.

Simple Solution

To tackle this problem we developed a simple open source library called Angulartics2. By plugging Angulartics2 in your Angular apps it will automatically track navigation events and send them to your plugged in Provider, such as Google Analytics.

Angulartics2 also comes with easy ways to send custom events to your providers enabling you to easily send any kind of event such as when your users buy an article or download a file. This is mostly useful for tracking conversion within your apps.

Diving into some simple code snippets

Plugging Angulartics2 into your Angular app is simple and similar to any other module:

You have to import Angulartics2Module.forRoot() in your main module and pass an array with the providers you are using.

Then, in you main component you need to pass each provider to the component constructor function. And that’s it, you now have automatic page tracking.

Make sure you also import the RouterModule in your main module. Angulartics2 uses Router to track your app’s current state.

Tracking custom events

After setting up Angulartics2 you can then easily trigger custom events:

You just need to import Angulartics2Module.forChild() in your modules and use angulartics2On directive in your templates.

You can also trigger custom events programmatically, by injecting Angulartics2 service in your components.

Angulartics2 is under active development and maintenance and we will be adding new providers based on community’s requests.

We currently support providers for:
Google Analytics
Google Tag Manager
Baidu Analytics
Facebook Pixel

As most good work, this could not be done without the help of great contributors. Many thanks for all the help to: Nathan Walker, Jonathan Reyes, Niels Kristian, Roland Oldengarm, kris, Tim Elfelt, Matthew Daniels, Adam S. Kirschner, Hongbo Miao, Smithi and Júlio César.

Your future app is here!
Simulate Pricing Start your Project