Selaa lähdekoodia

fix analytics

AykutSarac 3 vuotta sitten
vanhempi
commit
f46b2cccdc
2 muutettua tiedostoa jossa 17 lisäystä ja 23 poistoa
  1. 0 22
      src/components/GoogleAnalytics/index.tsx
  2. 17 1
      src/pages/_document.tsx

+ 0 - 22
src/components/GoogleAnalytics/index.tsx

@@ -1,22 +0,0 @@
-import React from "react";
-
-export const GoogleAnalytics: React.FC = () => {
-  return (
-    <>
-      <script
-        async
-        src="https://www.googletagmanager.com/gtag/js?id=G-JKZEHMJBMH"
-      />
-      <script
-        dangerouslySetInnerHTML={{
-          __html: `window.dataLayer = window.dataLayer || [];
-            function gtag(){dataLayer.push(arguments);}
-            gtag('js', new Date());
-          
-            gtag('config', 'G-JKZEHMJBMH');
-      `,
-        }}
-      />
-    </>
-  );
-};

+ 17 - 1
src/pages/_document.tsx

@@ -42,7 +42,23 @@ class MyDocument extends Document {
     return (
       <Html lang="en">
         <Head>
-          {!isDevelopment && <GoogleAnalytics />}
+          {!isDevelopment && (
+            <>
+              <script
+                async
+                src="https://www.googletagmanager.com/gtag/js?id=G-JKZEHMJBMH"
+              />
+              <script
+                dangerouslySetInnerHTML={{
+                  __html: `window.dataLayer = window.dataLayer || [];
+                          function gtag(){dataLayer.push(arguments);}
+                          gtag('js', new Date());
+                          gtag('config', 'G-JKZEHMJBMH');
+                    `,
+                }}
+              />
+            </>
+          )}
           <SeoTags
             description="Simple visualization tool for your JSON data. No forced structure, paste your JSON and view it instantly."
             title="JSON Visio"