Skip to content

Commit 8c4a53e

Browse files
committed
feat: integrate Google Tag Manager for production environment tracking
1 parent e86aea3 commit 8c4a53e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

apps/ticket/src/app/layout.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import "@/styles/reset.css";
1010
import "@/styles/global.scss";
1111
import { Header } from "@/shared/components/Header";
1212
import { Footer } from "@/shared/components/Footer";
13+
import Script from "next/script";
1314

1415
export const metadata: Metadata = {
1516
title: "Permit",
@@ -21,8 +22,28 @@ export default function RootLayout({
2122
}: Readonly<{
2223
children: React.ReactNode;
2324
}>) {
25+
const isProd = process.env.NODE_ENV === "production";
26+
2427
return (
2528
<html lang="ko">
29+
<head>
30+
{isProd && (
31+
<>
32+
<Script
33+
src="https://www.googletagmanager.com/gtag/js?id=G-R0HMHE4ZHF"
34+
strategy="afterInteractive"
35+
/>
36+
<Script id="gtag-init" strategy="afterInteractive">
37+
{`
38+
window.dataLayer = window.dataLayer || [];
39+
function gtag(){dataLayer.push(arguments);}
40+
gtag('js', new Date());
41+
gtag('config', 'G-R0HMHE4ZHF');
42+
`}
43+
</Script>
44+
</>
45+
)}
46+
</head>
2647
<body>
2748
<GlobalErrorBoundary>
2849
<QueryClientProviders>

0 commit comments

Comments
 (0)