ユーザーアイコン

mizuko

約1か月前

0
0

Next.jsでGA4を設定する

Next.js
GA4

@next/third-parties/googleを使う。 公式の記載通り設定する。

export default async function RootLayout({ children, }: { children: React.ReactNode; }): Promise<JSX.Element> { ~ 略 ~ return ( <html lang='ja'> ~ 略 ~ <body> ~ 略 ~ {!!process.env.GA_ID && <GoogleAnalytics gaId={process.env.GA_ID} />} </body> </html> ); }