1 import { Injectable } from '@angular/core';
2 import { NavigationEnd, Router } from '@angular/router';
3 import { Location } from '@angular/common';
5 import { filter } from 'rxjs/operator/filter';
10 export class AnalyticsService {
11 private enabled: boolean;
13 constructor(private location: Location, private router: Router) {
19 filter.call(this.router.events, (event) => event instanceof NavigationEnd)
21 ga('send', {hitType: 'pageview', page: this.location.path()});
26 trackEvent(eventName: string) {
28 ga('send', 'event', eventName);