mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
6284d41f0d
### What? Replaced the `GoogleTagManager` component with `GoogleAnalytics` in the `with-google-analytics` example. ### Why? The current implementation does not align with the [docs](https://nextjs.org/docs/app/building-your-application/optimizing/third-party-libraries#google-analytics), and a separate GTM example already exists. ### How? Replaced the `GoogleTagManager` component with `GoogleAnalytics`. Co-authored-by: Sam Ko <sam@vercel.com>
21 lines
461 B
TypeScript
21 lines
461 B
TypeScript
import { GoogleAnalytics } from "@next/third-parties/google";
|
|
|
|
export const metadata = {
|
|
title: "Google Analytics Next.js",
|
|
description:
|
|
"This example shows how to use Next.js along with Google Analytics.",
|
|
};
|
|
|
|
export default function RootLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
return (
|
|
<html lang="en">
|
|
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GA_ID as string} />
|
|
<body>{children}</body>
|
|
</html>
|
|
);
|
|
}
|