Skip to content

Commit 94fdb37

Browse files
committed
⚙ chore(#142): GoogleAnalytics 세팅
1 parent bc66732 commit 94fdb37

2 files changed

Lines changed: 42 additions & 16 deletions

File tree

src/app/layout.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
import Providers from "./providers";
2-
import { GoogleAnalytics, GoogleTagManager } from "@next/third-parties/google";
1+
import GoogleAnalytics from '@/lib/GoogleAnalytics';
2+
import Providers from './providers';
3+
import { GoogleTagManager } from '@next/third-parties/google';
34

45
export const metadata = {
5-
title: "레터링 | 온라인 편지 아카이빙 플랫폼",
6-
titleTemplate: "%s - 레터링",
6+
title: '레터링 | 온라인 편지 아카이빙 플랫폼',
7+
titleTemplate: '%s - 레터링',
78
description:
8-
"다양한 우주 행성 그리고 별빛이 담긴 편지지로 마음을 형상화한 편지를 보관해보세요.",
9+
'다양한 우주 행성 그리고 별빛이 담긴 편지지로 마음을 형상화한 편지를 보관해보세요.',
910
icons: {
10-
icon: "/favicon_16.png",
11+
icon: '/favicon_16.png'
1112
},
1213
openGraph: {
13-
site_name: "레터링",
14-
title: "레터링 | 온라인 편지 아카이빙 플랫폼",
14+
site_name: '레터링',
15+
title: '레터링 | 온라인 편지 아카이빙 플랫폼',
1516
description:
16-
"다양한 우주 행성 그리고 별빛이 담긴 편지지로 마음을 형상화한 편지를 보관해보세요.",
17-
url: "https://www.lettering.world",
18-
type: "website",
19-
},
17+
'다양한 우주 행성 그리고 별빛이 담긴 편지지로 마음을 형상화한 편지를 보관해보세요.',
18+
url: 'https://www.lettering.world',
19+
type: 'website'
20+
}
2021
};
2122

2223
export default function RootLayout({
23-
children,
24+
children
2425
}: Readonly<{
2526
children: React.ReactNode;
2627
}>) {
@@ -60,14 +61,14 @@ export default function RootLayout({
6061
a.getElementsByTagName('head')[0].appendChild(s);
6162
m.mazeUniversalSnippetApiKey = e;
6263
})(window, document, 'https://snippet.maze.co/maze-universal-loader.js', '697c563b-a019-4f27-8185-5f33599d9c4d');
63-
`,
64+
`
6465
}}
6566
/>
6667
</head>
6768
<body>
6869
<Providers>{children}</Providers>
69-
<GoogleTagManager gtmId="GTM-K4JD5J82" />
70-
<GoogleAnalytics gaId="G-RT86Q6W1PP" />
70+
<GoogleTagManager gtmId={process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER} />
71+
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS} />
7172
</body>
7273
</html>
7374
);

src/lib/GoogleAnalytics.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Script from 'next/script';
2+
3+
export default function GoogleAnalytics({ gaId }: { gaId: string }) {
4+
return (
5+
<>
6+
<Script
7+
async
8+
src={`https://www.googletagmanager.com/gtag/js
9+
?id=${gaId}`}
10+
/>
11+
<Script
12+
id="google-analytics"
13+
dangerouslySetInnerHTML={{
14+
__html: `
15+
window.dataLayer = window.dataLayer || [];
16+
function gtag(){dataLayer.push(arguments);}
17+
gtag('js', new Date());
18+
19+
gtag('config', '${gaId}');
20+
`
21+
}}
22+
/>
23+
</>
24+
);
25+
}

0 commit comments

Comments
 (0)