Skip to content

Commit

Permalink
Add plausible analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
jannismilz committed Nov 21, 2023
1 parent 26f5faa commit c4469ef
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions pages/_document.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
import Document, { Html, Head, Main, NextScript } from 'next/document'
import Document, { Html, Head, Main, NextScript } from "next/document";

class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
const initialProps = await Document.getInitialProps(ctx);
return { ...initialProps };
}

render() {
return (
<Html>
<Head>
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=G-${process.env.google_analytics}`}
/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-${process.env.google_analytics}', {
page_path: window.location.pathname,
});
`,
}}
/>
defer
data-domain="jannismilz.com"
src="https://analytics.jannismilz.com/js/script.js"
></script>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
);
}
}

export default MyDocument
export default MyDocument;

0 comments on commit c4469ef

Please sign in to comment.