Skip to content

Commit 8815faa

Browse files
committed
feat: add Google Analytics tracking scripts to RootLayout component
1 parent 8426a27 commit 8815faa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/app/layout.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import CommonProviders from "@/components/providers/CommonProviders";
77
import I18nProvider from "@/components/providers/I18nProvider";
88
import { fontKohinoorBanglaRegular } from "@/lib/fonts";
99
import { cookies } from "next/headers";
10+
import Script from "next/script";
1011
import React, { PropsWithChildren } from "react";
1112

1213
export const metadata: Metadata = {
@@ -37,6 +38,18 @@ const RootLayout: React.FC<PropsWithChildren> = async ({ children }) => {
3738
return (
3839
<html lang="en" suppressHydrationWarning>
3940
<body style={fontKohinoorBanglaRegular.style}>
41+
<Script
42+
src="https://www.googletagmanager.com/gtag/js?id=G-F3VRW4H09N"
43+
strategy="afterInteractive"
44+
/>
45+
<Script id="google-analytics" strategy="afterInteractive">
46+
{`
47+
window.dataLayer = window.dataLayer || [];
48+
function gtag(){dataLayer.push(arguments);}
49+
gtag('js', new Date());
50+
gtag('config', 'G-F3VRW4H09N');
51+
`}
52+
</Script>
4053
<I18nProvider currentLanguage={_cookies.get("language")?.value || "en"}>
4154
<CommonProviders session={session}>
4255
{children}

0 commit comments

Comments
 (0)