Skip to content

Commit 314c42d

Browse files
committed
Add Google Analytics to RootLayout
Import GoogleAnalytics from @next/third-parties and render it in app/layout.tsx using GA ID G-3J7N3BKGKM. Add @next/third-parties to package.json and update the pnpm lockfile to include the new dependency and its transitive entries so the analytics package is installed and reproducible.
1 parent 633815b commit 314c42d

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

app/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Metadata } from "next";
2+
import { GoogleAnalytics } from "@next/third-parties/google";
23
import "./globals.css";
34
import { inter } from "./fonts";
45

@@ -14,7 +15,10 @@ export default function RootLayout({
1415
}) {
1516
return (
1617
<html lang="en">
17-
<body className={inter.className}>{children}</body>
18+
<body className={inter.className}>
19+
{children}
20+
<GoogleAnalytics gaId="G-3J7N3BKGKM" />
21+
</body>
1822
</html>
1923
);
2024
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "eslint"
1010
},
1111
"dependencies": {
12+
"@next/third-parties": "^16.1.6",
1213
"class-variance-authority": "^0.7.1",
1314
"clsx": "^2.1.1",
1415
"html-to-image": "^1.11.13",

pnpm-lock.yaml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)