mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-01-01 07:08:49 +01:00
feat(analytics): update analytics service, use google tag manager (#1932)
This commit is contained in:
parent
52e3126141
commit
b8726fc314
4 changed files with 9 additions and 23 deletions
|
|
@ -20,28 +20,18 @@ export class AnalyticsService {
|
|||
filter((event) => event instanceof NavigationEnd),
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.gtm({'pageview': this.location.path()});
|
||||
this.gtmPushToDataLayer({event: 'pageView' , path: this.location.path()});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
trackEvent(eventName: string, eventVal: string = '') {
|
||||
if (this.enabled) {
|
||||
this.gtm({ event: eventName, value: eventVal });
|
||||
this.gtmPushToDataLayer({ event: eventName, eventValue: eventVal });
|
||||
}
|
||||
}
|
||||
|
||||
private isGaLoaded() {
|
||||
return this.window.ga;
|
||||
}
|
||||
|
||||
private gtm(params) {
|
||||
if (this.isGaLoaded()) {
|
||||
this.window.dataLayer.push(params);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.gtm(params);
|
||||
}, 500);
|
||||
}
|
||||
private gtmPushToDataLayer(params) {
|
||||
this.window.dataLayer.push(params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export class HeaderComponent implements OnInit , OnDestroy {
|
|||
}
|
||||
|
||||
if (selection && selection.toString() === 'contact@akveo.com') {
|
||||
this.analytics.trackEvent('contactEmail', 'select');
|
||||
this.analytics.trackEvent('clickContactEmail', 'select');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ export class HeaderComponent implements OnInit , OnDestroy {
|
|||
}
|
||||
|
||||
trackEmailClick() {
|
||||
this.analytics.trackEvent('contactEmail', 'click');
|
||||
this.analytics.trackEvent('clickContactEmail', 'click');
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import { NbThemeService, NbPopoverDirective } from '@nebular/theme';
|
||||
import { AnalyticsService } from '../../../../@core/utils/analytics.service';
|
||||
import { NbJSThemeOptions } from '@nebular/theme/services/js-themes/theme.options';
|
||||
|
||||
@Component({
|
||||
|
|
@ -38,14 +37,11 @@ export class ThemeSwitcherListComponent {
|
|||
},
|
||||
];
|
||||
|
||||
constructor(
|
||||
private themeService: NbThemeService,
|
||||
private analyticsService: AnalyticsService,
|
||||
) {}
|
||||
constructor(private themeService: NbThemeService) {
|
||||
}
|
||||
|
||||
onToggleTheme(themeKey: string) {
|
||||
this.themeService.changeTheme(themeKey);
|
||||
this.analyticsService.trackEvent('switchTheme');
|
||||
this.popover.hide();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export class AppComponent implements OnInit {
|
|||
|
||||
this.themeService.onThemeChange()
|
||||
.subscribe((theme: any) => {
|
||||
this.analytics.trackEvent('themeUsed', theme.name);
|
||||
this.analytics.trackEvent('changeTheme', theme.name);
|
||||
});
|
||||
|
||||
this.activatedRoute.queryParams
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue