Skip to content

Commit

Permalink
feat(analytics): add google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonsaldan committed Dec 27, 2024
1 parent 3d31cc3 commit 982401c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import GoogleAnalytics from '@/components/google-analytics'
import '@/styles/tailwind.css'
import type { Metadata } from 'next'

Expand Down Expand Up @@ -59,9 +60,6 @@ export const metadata: Metadata = {
'When Spotify ended support, we created a new beginning. Join our growing community of users giving their Car Thing a second life with our free, open source solution.',
images: ['https://usenocturne.com/images/og-image.png'],
},
verification: {
google: 'G-YB8VYY7389',
},
other: {
wikidata: 'Q131441227',
wikipedia: 'https://wikipedia.org/wiki/Nocturne_(software)',
Expand Down Expand Up @@ -187,7 +185,10 @@ export default function RootLayout({
}}
/>
</head>
<body className="text-gray-950 antialiased">{children}</body>
<body className="text-gray-950 antialiased">
<GoogleAnalytics />
{children}
</body>
</html>
)
}
20 changes: 20 additions & 0 deletions src/components/google-analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Script from 'next/script'

export default function GoogleAnalytics() {
return (
<>
<Script
src="https://www.googletagmanager.com/gtag/js?id=G-4J3JC66HC2"
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-4J3JC66HC2');
`}
</Script>
</>
)
}

0 comments on commit 982401c

Please sign in to comment.