mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-23 02:40:14 +01:00
feat: demo version additions
This commit is contained in:
parent
06cda13fd0
commit
62e6828680
36 changed files with 1494 additions and 65 deletions
|
|
@ -1,16 +1,17 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { filter } from 'rxjs/operators';
|
||||
|
||||
declare const ga: any;
|
||||
import { NB_WINDOW } from '@nebular/theme';
|
||||
|
||||
@Injectable()
|
||||
export class AnalyticsService {
|
||||
private enabled: boolean;
|
||||
private enabled = false;
|
||||
|
||||
constructor(private location: Location, private router: Router) {
|
||||
this.enabled = false;
|
||||
constructor(@Inject(NB_WINDOW) private window,
|
||||
private location: Location,
|
||||
private router: Router) {
|
||||
this.enabled = this.window.location.href.indexOf('akveo.com') >= 0;
|
||||
}
|
||||
|
||||
trackPageViews() {
|
||||
|
|
@ -19,14 +20,18 @@ export class AnalyticsService {
|
|||
filter((event) => event instanceof NavigationEnd),
|
||||
)
|
||||
.subscribe(() => {
|
||||
ga('send', {hitType: 'pageview', page: this.location.path()});
|
||||
this.gtmPushToDataLayer({event: 'pageView' , path: this.location.path()});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
trackEvent(eventName: string) {
|
||||
trackEvent(eventName: string, eventVal: string = '') {
|
||||
if (this.enabled) {
|
||||
ga('send', 'event', eventName);
|
||||
this.gtmPushToDataLayer({ event: eventName, eventValue: eventVal });
|
||||
}
|
||||
}
|
||||
|
||||
private gtmPushToDataLayer(params) {
|
||||
this.window.dataLayer.push(params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue