From c019de67c6cee388ecd299ff1545f39e073d5f21 Mon Sep 17 00:00:00 2001 From: denStrigo Date: Thu, 22 Nov 2018 18:14:43 +0300 Subject: [PATCH] fix(analytics): update analytics service, add detection if google analytics was loaded --- src/app/@core/utils/analytics.service.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/@core/utils/analytics.service.ts b/src/app/@core/utils/analytics.service.ts index 2cb0b271..6772fdea 100644 --- a/src/app/@core/utils/analytics.service.ts +++ b/src/app/@core/utils/analytics.service.ts @@ -28,8 +28,14 @@ export class AnalyticsService { } trackEvent(eventName: string, eventVal: string = '') { - if (this.enabled) { + if (this.enabled && this.window.ga) { ga('send', 'event', eventName, eventVal); } + + if (!this.window.ga) { + setTimeout(() => { + this.trackEvent(eventName, eventVal); + }, 500); + } } }