From 8f28ba28ec47cd3ca83ffb703c263f419c889bb1 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Fri, 19 Jul 2019 13:17:52 +0530 Subject: [PATCH] added ga (#107) * fixes * make monaco workers available in static folder * fixes * fixes * fix(worker): monaco workers path * chore(ga): added google analytics --- pages/_document.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pages/_document.tsx b/pages/_document.tsx index 8f176b0..2bc1952 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -8,15 +8,19 @@ interface DocumentProps { } function trackingScript() { - window["dataLayer"] = window["dataLayer"] || []; + // @ts-ignore + if (window.dataLayer) return; + // @ts-ignore + window.dataLayer = window.dataLayer || []; function gtag() { - window["dataLayer"].push(arguments); + // @ts-ignore + window.dataLayer.push(arguments); } // @ts-ignore gtag("js", new Date()); // @ts-ignore - gtag("config", "UA-60624235-5"); + gtag("config", "UA-60624235-8"); } export default class MyDocument extends Document { @@ -31,10 +35,6 @@ export default class MyDocument extends Document { }; } - componentDidMount(): void { - trackingScript(); - } - render() { const { css, hydrationScript } = this.props; @@ -56,8 +56,11 @@ export default class MyDocument extends Document { );