Skip to content

Commit

Permalink
feat(): ga can be disabled with local storage key ga_debug_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hirsch88 committed Aug 22, 2024
1 parent 6ca51e8 commit 289bb13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/google-tag-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export class BalGoogleTagManager {
applicationName: string;

public isEnabled(): boolean {
return (window as any)[DATA_LAYER] != null;
const win = window
return win && ((win as any)[DATA_LAYER] != null || win.localStorage.getItem('ga_debug_mode') === 'true');
}

public load(settings: GtmSettings): void {
Expand All @@ -31,11 +32,11 @@ export class BalGoogleTagManager {
public sendClickEvent(label: string): void {
if (label) {
this.googleAnalyticsSendEvent({
event: VIRTUAL_FUNNEL_CLICK,
VirtualClickCategory: VIRTUAL_FUNNEL_CLICK,
VirtualClickAction: this.applicationName,
VirtualClickLabel: label
});
event: VIRTUAL_FUNNEL_CLICK,
VirtualClickCategory: VIRTUAL_FUNNEL_CLICK,
VirtualClickAction: this.applicationName,
VirtualClickLabel: label
});
}
};

Expand Down

0 comments on commit 289bb13

Please sign in to comment.