Skip to content

Commit

Permalink
feat(app): added gtag functions
Browse files Browse the repository at this point in the history
  • Loading branch information
abedzantout committed Sep 13, 2019
1 parent 28a1cd3 commit fcb40b7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions core/gtag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const GA_TRACKING_ID = '';

const isProduction = process.env.NODE_ENV.toLowerCase() === 'production';

// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
export const trackPageView = url => {
// @ts-ignore
window.gtag('config', GA_TRACKING_ID, {
page_path: url,
});
};

// https://developers.google.com/analytics/devguides/collection/gtagjs/events
export const trackEvent = ({action, category, label, value}) => {
// @ts-ignore
window.gtag('event', action, {
event_category: category,
event_label: label,
value: value,
});
};

0 comments on commit fcb40b7

Please sign in to comment.