Files
suu3 6284d41f0d examples: replaced GTM component with GA in Google Analytics example (#73597)
### 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>
2024-12-10 06:45:49 +00:00

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>
);
}