diff --git a/src/app/@core/utils/analytics.service.ts b/src/app/@core/utils/analytics.service.ts index 30629331..e9a14d6d 100644 --- a/src/app/@core/utils/analytics.service.ts +++ b/src/app/@core/utils/analytics.service.ts @@ -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); } } diff --git a/src/app/@theme/components/header/header.component.ts b/src/app/@theme/components/header/header.component.ts index 861569b5..2f92d57c 100644 --- a/src/app/@theme/components/header/header.component.ts +++ b/src/app/@theme/components/header/header.component.ts @@ -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() { diff --git a/src/app/@theme/components/theme-switcher/themes-switcher-list/themes-switcher-list.component.ts b/src/app/@theme/components/theme-switcher/themes-switcher-list/themes-switcher-list.component.ts index b3a16391..b44ba7ad 100644 --- a/src/app/@theme/components/theme-switcher/themes-switcher-list/themes-switcher-list.component.ts +++ b/src/app/@theme/components/theme-switcher/themes-switcher-list/themes-switcher-list.component.ts @@ -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(); } } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 3e4d0343..a2d19c3e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -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