Skip to content

Commit f2c0bcc

Browse files
committed
feat: Google Analytics 스크립트 추가 및 설정
1 parent 782e596 commit f2c0bcc

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

.vitepress/config.mts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { generateSidebar } from "./plugins/sidebar";
33

44
import { createAutoGeneratePostsPlugin } from "./plugins/posts";
55

6+
const GOOGLE_ANALYTICS_ID = "G-3XM039P5E6";
7+
68
// https://vitepress.dev/reference/site-config
79
export default defineConfig({
810
title: "🦷 ToothlessDev",
@@ -47,7 +49,6 @@ export default defineConfig({
4749
hostname: "https://toothlessdev.github.io/",
4850
},
4951

50-
// URL 리라이트 설정 - /posts/* -> /pages/posts/*
5152
rewrites: {
5253
"pages/posts/index.md": "posts/index.md",
5354
"pages/posts/:slug*": "posts/:slug*",
@@ -58,4 +59,24 @@ export default defineConfig({
5859
vite: {
5960
plugins: [createAutoGeneratePostsPlugin()],
6061
},
62+
63+
head: [
64+
[
65+
"script",
66+
{
67+
async: "",
68+
src: `https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ANALYTICS_ID}`,
69+
},
70+
],
71+
[
72+
"script",
73+
{},
74+
`
75+
window.dataLayer = window.dataLayer || [];
76+
function gtag() { dataLayer.push(arguments); }
77+
gtag('js', new Date());
78+
gtag('config', '${GOOGLE_ANALYTICS_ID}');
79+
`,
80+
],
81+
],
6182
});

0 commit comments

Comments
 (0)