diff --git a/src/index.tsx b/src/index.tsx index 3709d38..b079361 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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."); diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 07eb038..af95072 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -4,4 +4,5 @@ interface Window { NODE_ENV: string; }; gtag: Function; + dataLayer: Array; }