Skip to content

Commit

Permalink
fix(analytics): update analytics service (#37)
Browse files Browse the repository at this point in the history
* fix(analytics): update analytics service

* fix(analytics): update analytics service, remove ga detection
  • Loading branch information
denStrigo authored Nov 26, 2018
1 parent 9298aa7 commit 5d18d12
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/@theme/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions src/app/@theme/services/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import { Injectable, Inject } from '@angular/core';
import { NB_WINDOW } from '@nebular/theme';
declare const ga: any;

@Injectable()
export class EvaAnalytics {
Expand All @@ -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);
}
}
4 changes: 3 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!doctype html>
<html lang="en">
<head>

<script>
dataLayer = [];
</script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
Expand Down

0 comments on commit 5d18d12

Please sign in to comment.