ga only in prod

This commit is contained in:
Kalle (Sendou) 2021-01-12 12:05:31 +02:00
parent 6231c67030
commit b27d338fb6

View File

@ -21,13 +21,15 @@ class MyDocument extends Document {
<Html>
<Head>
{/* Global Site Tag (gtag.js) - Google Analytics */}
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
/>
<script
dangerouslySetInnerHTML={{
__html: `
{process.env.NODE_ENV === "production" && (
<>
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
@ -35,8 +37,10 @@ class MyDocument extends Document {
page_path: window.location.pathname,
});
`,
}}
/>
}}
/>
</>
)}
</Head>
<body>
<ColorModeScript />