Skip to content

Commit

Permalink
manually add GA to index GRRR
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfay committed Feb 6, 2024
1 parent 4449099 commit 12d47d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
21 changes: 0 additions & 21 deletions src/analytics/GoogleAnalytics.tsx

This file was deleted.

20 changes: 17 additions & 3 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
import Document, { Head, Html, Main, NextScript } from 'next/document';
import Script from 'next/script';

import { GoogleAnalytics } from '../analytics/GoogleAnalytics';
import { AppConfig } from '../utils/AppConfig';

const gtmId = 'G-NV5LK0T9C1';

// Need to create a custom _document because i18n support is not compatible with `next export`.
class MyDocument extends Document {
// eslint-disable-next-line class-methods-use-this
render() {
return (
<Html lang={AppConfig.locale}>
<Head></Head>
<Head>
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${gtmId}`}
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${gtmId}');
`}
</Script>
</Head>
<body className="testing">
<Main />
<NextScript />
</body>
<GoogleAnalytics />
</Html>
);
}
Expand Down

0 comments on commit 12d47d9

Please sign in to comment.