diff --git a/src/app/@core/utils/analytics.service.ts b/src/app/@core/utils/analytics.service.ts
index 6772fdea..f5484ab4 100644
--- a/src/app/@core/utils/analytics.service.ts
+++ b/src/app/@core/utils/analytics.service.ts
@@ -22,19 +22,27 @@ export class AnalyticsService {
filter((event) => event instanceof NavigationEnd),
)
.subscribe(() => {
- ga('send', {hitType: 'pageview', page: this.location.path()});
+ this.gtm({'pageview': this.location.path()});
});
}
}
trackEvent(eventName: string, eventVal: string = '') {
- if (this.enabled && this.window.ga) {
- ga('send', 'event', eventName, eventVal);
+ if (this.enabled) {
+ this.gtm({ event: eventName, value: eventVal });
}
+ }
- if (!this.window.ga) {
+ private isGaLoaded() {
+ return this.window.ga;
+ }
+
+ private gtm(params) {
+ if (this.isGaLoaded()) {
+ this.window.dataLayer.push(params);
+ } else {
setTimeout(() => {
- this.trackEvent(eventName, eventVal);
+ this.gtm(params);
}, 500);
}
}
diff --git a/src/index.html b/src/index.html
index e79ebf31..8f6f1639 100644
--- a/src/index.html
+++ b/src/index.html
@@ -11,6 +11,9 @@
+