Skip to content

Commit 7d05659

Browse files
committed
fix: add google Analytics
1 parent 5dd69bd commit 7d05659

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/app/[locale]/layout.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ElevationScrollAppBar } from './ElevationScrollAppBar';
1212

1313
import 'highlight.js/styles/github-dark.css';
1414
import './global.css';
15+
import Script from 'next/script';
1516

1617
const geist = Geist({
1718
subsets: ['latin'],
@@ -35,6 +36,22 @@ export default async function RootLayout({
3536
return (
3637
<html lang={locale} suppressHydrationWarning className={geist.className}>
3738
<body>
39+
<Script
40+
src="https://www.googletagmanager.com/gtag/js?id=G-1P80WT42PB"
41+
strategy="afterInteractive"
42+
/>
43+
<Script
44+
id="google-analytics"
45+
strategy="afterInteractive"
46+
dangerouslySetInnerHTML={{
47+
__html: `
48+
window.dataLayer = window.dataLayer || [];
49+
function gtag(){dataLayer.push(arguments);}
50+
gtag('js', new Date());
51+
gtag('config', 'G-1P80WT42PB');
52+
`,
53+
}}
54+
/>
3855
<I18nProvider locale={locale}>
3956
<AppRouterCacheProvider options={{ key: 'css' }}>
4057
<NextThemeProvider>

0 commit comments

Comments
 (0)