Skip to content

Commit b57b328

Browse files
committed
ga -> gtm 으로 이동
1 parent b7bd9c0 commit b57b328

File tree

5 files changed

+20
-35
lines changed

5 files changed

+20
-35
lines changed

.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Google Analytics with nextjs-google-analytics
2-
NEXT_PUBLIC_GA_MEASUREMENT_ID=G-xxxxxx
1+
# Google Tag Manager
2+
NEXT_PUBLIC_GTM_ID=G-xxxxxx
33

44
# utterances
55
# https://github.com/utterance/utterances

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"lucide-react": "^0.471.1",
3131
"next": "15.1.4",
3232
"next-seo": "^6.6.0",
33-
"nextjs-google-analytics": "^2.3.7",
3433
"react": "19.0.0",
3534
"react-dom": "19.0.0",
3635
"react-wrap-balancer": "^1.1.1",

pnpm-lock.yaml

-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/layout.tsx

+18-14
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ window.CodenButter("boot", { siteId: "otoyyikrrj", auto: true });
4848
}}
4949
></script>
5050
{/* GTM */}
51-
<script
52-
dangerouslySetInnerHTML={{
53-
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
51+
{process.env.NEXT_PUBLIC_GTM_ID ? (
52+
<script
53+
dangerouslySetInnerHTML={{
54+
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
5455
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
5556
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
5657
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
57-
})(window,document,'script','dataLayer','GTM-T4CTRV8V');`,
58-
}}
59-
></script>
58+
})(window,document,'script','dataLayer','${process.env.NEXT_PUBLIC_GTM_ID}');`,
59+
}}
60+
></script>
61+
) : null}
6062
<script
6163
dangerouslySetInnerHTML={{
6264
__html: `
@@ -71,14 +73,16 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
7173
></script>
7274
</head>
7375
<body>
74-
<noscript>
75-
<iframe
76-
src="https://www.googletagmanager.com/ns.html?id=GTM-T4CTRV8V"
77-
height="0"
78-
width="0"
79-
style={{ display: "none", visibility: "hidden" }}
80-
></iframe>
81-
</noscript>
76+
{process.env.NEXT_PUBLIC_GTM_ID ? (
77+
<noscript>
78+
<iframe
79+
src={`https://www.googletagmanager.com/ns.html?id=${process.env.NEXT_PUBLIC_GTM_ID}`}
80+
height="0"
81+
width="0"
82+
style={{ display: "none", visibility: "hidden" }}
83+
></iframe>
84+
</noscript>
85+
) : null}
8286

8387
<Providers>
8488
<ColorModeClassNameInjector />

src/app/providers.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { store } from "@modules/color-mode/color-mode";
55
import { NextUIProvider } from "@nextui-org/react";
66
import { Provider as JotaiProvider } from "jotai";
77
import { useRouter } from "next/navigation";
8-
import { GoogleAnalytics } from "nextjs-google-analytics";
98
import { useCallback } from "react";
109

1110
export function Providers({ children }: { children: React.ReactNode }) {
@@ -20,7 +19,6 @@ export function Providers({ children }: { children: React.ReactNode }) {
2019

2120
return (
2221
<NextUIProvider navigate={navigate} locale="ko-KR">
23-
<GoogleAnalytics trackPageViews />
2422
<JotaiProvider store={store}>{children}</JotaiProvider>
2523
</NextUIProvider>
2624
);

0 commit comments

Comments
 (0)