Skip to content

Commit

Permalink
docs: setup analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 30, 2020
1 parent f31ed40 commit 212be8c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import Document, { Head, Html, Main, NextScript } from 'next/document'

const ga = process.env.NEXT_PUBLIC_GA

export default class _DocumentPage extends Document {
render() {
return (
<Html>
<Head>
{ga && (
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=${ga}`}
/>
)}
{ga && (
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${ga}');
`,
}}
/>
)}
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700;900&family=Source+Sans+Pro&display=swap"
Expand Down

0 comments on commit 212be8c

Please sign in to comment.