Tracking page views in angulartics2

Angulartics2 is a great package for vendor agnostic tracking in Angular apps. When using the package with Google Analytics, page view tracking is wired up automatically using the Angular  routing module.


The angulartics2 documentation does not include information on how to send page views using the module however it is pretty simple to do, just inject the Angulartics2 and Angular common Location modules into your module’s constructor like so:

import { Angulartics2 } from 'angulartics2';
import {Location} from '@angular/common';

 private location: Location,
 public angulartics2: Angulartics2,

and you can now track page views manually using the following method:{ path: '/your-path/' + issue.slug, location: location });
Help other people find this

Leave a Reply

Your e-mail address will not be published. Required fields are marked *