From 205c7d7d77fe41525095a1e80b74ee4d6c74403c Mon Sep 17 00:00:00 2001 From: clolc Date: Mon, 20 Oct 2025 14:47:59 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20Google=20Adsense=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=BD=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/layout.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index ab09fa8..e2696ee 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -25,6 +25,14 @@ export default function RootLayout({ }>) { return ( + + {/* 구글 애드센스 스크립트 */} + + From cee134035a50c242df9ad4898da74dffaec55415 Mon Sep 17 00:00:00 2001 From: clolc Date: Mon, 20 Oct 2025 15:00:59 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20Google=20Anayltics=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/layout.tsx | 4 ++++ src/components/GoogleAnalytics.tsx | 37 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/components/GoogleAnalytics.tsx diff --git a/src/app/layout.tsx b/src/app/layout.tsx index e2696ee..d89639b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata } from 'next'; import { Geist, Geist_Mono } from 'next/font/google'; import '@/styles/globals.css'; import ClientHeader from '@/components/ClientHeader'; +import GoogleAnalytics from '@/components/GoogleAnalytics'; const geistSans = Geist({ variable: '--font-geist-sans', @@ -36,6 +37,9 @@ export default function RootLayout({ + {/* 구글 애널리틱스 컴포넌트 */} + + {/* 전역 헤더 */} diff --git a/src/components/GoogleAnalytics.tsx b/src/components/GoogleAnalytics.tsx new file mode 100644 index 0000000..308c60f --- /dev/null +++ b/src/components/GoogleAnalytics.tsx @@ -0,0 +1,37 @@ +'use client'; // 클라이언트 컴포넌트임을 명시합니다. + +import Script from 'next/script'; + +const GoogleAnalytics = () => { + const gaId = process.env.NEXT_PUBLIC_GA_ID; + + // 환경 변수가 설정되지 않았다면 아무것도 렌더링하지 않습니다. + if (!gaId) { + return null; + } + + return ( + <> + {/* 외부 gtag.js 스크립트를 로드합니다. */} +