Skip to content

Commit b36e9b3

Browse files
committed
feat: 프로덕션 환경에서만 Google Analytics 스크립트 로드
1 parent 36d7a6b commit b36e9b3

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

.vitepress/config.mts

Lines changed: 9 additions & 3 deletions
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 isProduction = process.env.NODE_ENV === "production";
7+
68
const GOOGLE_ANALYTICS_ID = "G-3XM039P5E6";
79
const NAVER_SITE_VERIFICATION_CODE = "596cb41268d676e378deaba826716cd18229d0b1";
810

@@ -65,18 +67,22 @@ export default defineConfig({
6567
"script",
6668
{
6769
async: "",
68-
src: `https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ANALYTICS_ID}`,
70+
src: isProduction
71+
? `https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ANALYTICS_ID}`
72+
: "",
6973
},
7074
],
7175
[
7276
"script",
7377
{},
74-
`
78+
isProduction
79+
? `
7580
window.dataLayer = window.dataLayer || [];
7681
function gtag() { dataLayer.push(arguments); }
7782
gtag('js', new Date());
7883
gtag('config', '${GOOGLE_ANALYTICS_ID}');
79-
`,
84+
`
85+
: "",
8086
],
8187
[
8288
"meta",

0 commit comments

Comments
 (0)