Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Only push events if the datalayer exists
Browse files Browse the repository at this point in the history
  • Loading branch information
solocommand committed Apr 1, 2021
1 parent da4944f commit 8587119
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/marko-web-native-x/utils/gtm-events.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export const pageLoad = (window) => {
const dataLayer = window.dataLayerNativeX || [];
dataLayer.push({ event: 'page_load' });
const dataLayer = window.dataLayerNativeX;
if (dataLayer) dataLayer.push({ event: 'page_load' });
};

export const outboundLink = (window, url) => {
const dataLayer = window.dataLayerNativeX || [];
dataLayer.push({ event: 'outbound_click', outbound_url: url, eventTimeout: 3000 });
const dataLayer = window.dataLayerNativeX;
if (dataLayer) dataLayer.push({ event: 'outbound_click', outbound_url: url, eventTimeout: 3000 });
};

export const share = (window, provider) => {
const dataLayer = window.dataLayerNativeX || [];
dataLayer.push({ event: 'share', social_provider: provider });
const dataLayer = window.dataLayerNativeX;
if (dataLayer) dataLayer.push({ event: 'share', social_provider: provider });
};

export const endOfContent = (window) => {
const dataLayer = window.dataLayerNativeX || [];
dataLayer.push({ event: 'scroll_to_bottom' });
const dataLayer = window.dataLayerNativeX;
if (dataLayer) dataLayer.push({ event: 'scroll_to_bottom' });
};

0 comments on commit 8587119

Please sign in to comment.