From 5d18d124f5c9ed957c42512d96545f9e25cb661b Mon Sep 17 00:00:00 2001 From: Denis Strigo Date: Mon, 26 Nov 2018 19:05:41 +0300 Subject: [PATCH] fix(analytics): update analytics service (#37) * fix(analytics): update analytics service * fix(analytics): update analytics service, remove ga detection --- src/app/@theme/components/header/header.component.ts | 2 +- .../modals/download-icon/download-icon.component.ts | 2 +- .../components/page-container/page-container.component.ts | 2 +- src/app/@theme/services/analytics.service.ts | 8 ++++++-- src/index.html | 4 +++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/app/@theme/components/header/header.component.ts b/src/app/@theme/components/header/header.component.ts index 513fa196..99e35673 100644 --- a/src/app/@theme/components/header/header.component.ts +++ b/src/app/@theme/components/header/header.component.ts @@ -27,6 +27,6 @@ export class HeaderComponent { clickOnDownloadPack() { const version = this.versionService.getEvoVersion(); - this.analytics.trackEvent('download-pack', `download pack version: ${version}`); + this.analytics.trackEvent('downloadPack', `download pack version: ${version}`); } } diff --git a/src/app/@theme/components/modals/download-icon/download-icon.component.ts b/src/app/@theme/components/modals/download-icon/download-icon.component.ts index 43fc3429..b9f8e410 100644 --- a/src/app/@theme/components/modals/download-icon/download-icon.component.ts +++ b/src/app/@theme/components/modals/download-icon/download-icon.component.ts @@ -40,6 +40,6 @@ export class DownloadIconComponent implements AfterViewInit { } clickOnDownloadIcon(icon: { format: string; title: string }) { - this.analytics.trackEvent('download-icon', `${this.selectedIcon}.${icon.format}`); + this.analytics.trackEvent('downloadIcon', `${this.selectedIcon}.${icon.format}`); } } diff --git a/src/app/@theme/components/page-container/page-container.component.ts b/src/app/@theme/components/page-container/page-container.component.ts index 18e2b227..d2520356 100644 --- a/src/app/@theme/components/page-container/page-container.component.ts +++ b/src/app/@theme/components/page-container/page-container.component.ts @@ -135,7 +135,7 @@ export class PageContainerComponent implements AfterViewInit, OnDestroy { } clickIcon(icon) { - this.analytics.trackEvent('open-icon-dialog', icon); + this.analytics.trackEvent('openIconDialog', icon); if (this.isMobileMode) { return; diff --git a/src/app/@theme/services/analytics.service.ts b/src/app/@theme/services/analytics.service.ts index 3012ce54..01f4cc9a 100644 --- a/src/app/@theme/services/analytics.service.ts +++ b/src/app/@theme/services/analytics.service.ts @@ -6,7 +6,6 @@ import { Injectable, Inject } from '@angular/core'; import { NB_WINDOW } from '@nebular/theme'; -declare const ga: any; @Injectable() export class EvaAnalytics { @@ -18,7 +17,12 @@ export class EvaAnalytics { trackEvent(eventName: string, eventVal: string = '') { if (this.enabled) { - ga('send', 'event', eventName, eventVal); + this.gtmPushToDataLayer({ event: eventName, eventValue: eventVal }); } } + + // Push to 'dataLayer' Google Tag Manager array + private gtmPushToDataLayer(params) { + this.window.dataLayer.push(params); + } } diff --git a/src/index.html b/src/index.html index 87f622c1..31851a16 100644 --- a/src/index.html +++ b/src/index.html @@ -1,7 +1,9 @@ - +