add GoogleAnalytics
This commit is contained in:
parent
bb60f67316
commit
9e1e70a1b6
@ -6,6 +6,7 @@ import 'katex/dist/katex.min.css'
|
||||
import { ThemeProvider } from '@/components/theme/ThemeProvider'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Toaster } from '@/components/ui/toaster'
|
||||
import { GoogleAnalytics } from '@/components/GoogleAnalytics'
|
||||
|
||||
const inter = Inter({ subsets: ['latin'] })
|
||||
|
||||
@ -46,6 +47,7 @@ export default function RootLayout({
|
||||
'min-h-screen bg-background font-sans antialiased',
|
||||
inter.className
|
||||
)}>
|
||||
<GoogleAnalytics />
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="system"
|
||||
|
22
src/components/GoogleAnalytics.tsx
Normal file
22
src/components/GoogleAnalytics.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
'use client'
|
||||
|
||||
import Script from 'next/script'
|
||||
|
||||
export function GoogleAnalytics() {
|
||||
return (
|
||||
<>
|
||||
<Script
|
||||
src="https://www.googletagmanager.com/gtag/js?id=G-Y51DW9V3F6"
|
||||
strategy="afterInteractive"
|
||||
/>
|
||||
<Script id="google-analytics" strategy="afterInteractive">
|
||||
{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'G-Y51DW9V3F6');
|
||||
`}
|
||||
</Script>
|
||||
</>
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user