Skip to content

Commit 86cac60

Browse files
committed
chore: GA 적용
1 parent 342229b commit 86cac60

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
.env

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"framer-motion": "^12.27.0",
1919
"react": "^19.2.0",
2020
"react-dom": "^19.2.0",
21+
"react-ga4": "^2.1.0",
2122
"react-router-dom": "^7.11.0"
2223
},
2324
"devDependencies": {

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/main.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import App from "@app/App";
21
import { StrictMode } from "react";
32
import { createRoot } from "react-dom/client";
3+
import ReactGA from "react-ga4";
44

5+
import App from "@app/App";
56
import { AppProviders } from "@app/providers";
67

78
import "@app/styles/global.css";
89

10+
ReactGA.initialize(import.meta.env.VITE_GA_TRACKING_ID);
11+
912
const rootEl = document.getElementById("root");
1013
if (!rootEl) throw new Error('Root element "#root" not found');
1114

src/pages/landing/landing-page.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { useRef } from "react";
2-
3-
import { CHARACTER, FLOAT_IMG, KEY } from "@/shared/assets/images";
4-
import useDevice from "@/shared/model/use-device";
5-
6-
import * as styles from "./landing-page.css";
2+
import ReactGA from "react-ga4";
73

84
import {
95
LandingCard,
@@ -13,13 +9,22 @@ import {
139
AlertModal,
1410
} from "@/features/landing";
1511
import { LANDING_CARD_ITEMS } from "@/features/landing/config/landing-card.constant";
12+
import { CHARACTER, FLOAT_IMG, KEY } from "@/shared/assets/images";
13+
import useDevice from "@/shared/model/use-device";
14+
15+
import * as styles from "./landing-page.css";
1616

1717
const LandingPage = () => {
1818
const { isMobile } = useDevice();
1919
const modalRef = useRef<HTMLDialogElement>(null);
2020
const sectionRef = useRef<HTMLDivElement>(null);
2121

2222
const handleModal = () => {
23+
ReactGA.event({
24+
category: "Button",
25+
action: "Click Button",
26+
label: "Click Service Button", // 어떤 버튼 요소인지 구별
27+
});
2328
modalRef.current?.showModal();
2429
};
2530

0 commit comments

Comments
 (0)