Skip to content

Commit

Permalink
Fix gtag setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaewoook committed Aug 9, 2022
1 parent 353c0fa commit 17c787a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ window.__ENV__ = {
NODE_ENV: process.env.REACT_APP_ENV as string,
};

window.dataLayer = window.dataLayer || [];
if (isProduction()) {
window.gtag = function(...args: any[]) {
window.dataLayer.push(args);
};
window.gtag("config", "G-NJFP4YL0X3", {
allow_google_signals: false,
allow_ad_personalization_signals: false,
});
window.gtag("js", new Date());
Sentry.init({ dsn: "https://6b96accd47ff467da8394a51da93d909@o415139.ingest.sentry.io/5305794" });
} else {
console.info("Google Analytics disabled because runtime does not running in production.");
Expand Down
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ interface Window {
NODE_ENV: string;
};
gtag: Function;
dataLayer: Array;
}

0 comments on commit 17c787a

Please sign in to comment.