From 5ae1a497bcda68bc396b289931da7d843e38979c Mon Sep 17 00:00:00 2001 From: Sayyed Sharuk Date: Thu, 4 Apr 2024 18:32:18 +0530 Subject: [PATCH] Fix ga --- src/components/AboutPage/ResumeButton.tsx | 5 +++++ src/pages/About/About.tsx | 6 ------ src/pages/Home/Home.tsx | 11 +++++------ src/vite-env.d.ts | 4 ++++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/AboutPage/ResumeButton.tsx b/src/components/AboutPage/ResumeButton.tsx index 675bf25..09f3b4b 100644 --- a/src/components/AboutPage/ResumeButton.tsx +++ b/src/components/AboutPage/ResumeButton.tsx @@ -1,9 +1,14 @@ import { Button, Flex } from "@chakra-ui/react"; import { ScalePing } from "../../animations/ScaleAnimations"; import { resumeDownload, resumelink } from "../../sources/Links"; +import ReactGA from "react-ga4"; const ResumeButton = () => { const handleResumeDownload = () => { + ReactGA.event({ + category: "Resume", + action: "Downloaded the Resume", + }); window.open(resumelink, "_blank"); }; return ( diff --git a/src/pages/About/About.tsx b/src/pages/About/About.tsx index b98df8c..faf637e 100644 --- a/src/pages/About/About.tsx +++ b/src/pages/About/About.tsx @@ -3,7 +3,6 @@ import { Flex } from "@chakra-ui/react"; import { ScrollContext } from "../../contexts/ScrollContext"; import MdHeading from "../../components/Headings/MdHeading"; import AboutCard from "../../components/AboutPage/AboutCard"; -import ReactGA from "react-ga4"; const About = () => { const context = useContext(ScrollContext); @@ -13,11 +12,6 @@ const About = () => { } const { AboutRef } = context; - ReactGA.event({ - category: "pagevisit", - action: `Viewed About Page`, - }); - return ( <> { const scrollContext = useContext(ScrollContext); const { isOpen, onOpen, onClose } = useDisclosure(); + useEffect(() => { + ReactGA.send({ hitType: "pageview", page: "/", title: "Visited Portfolio" }); + }, []); + if (!scrollContext) { return; } @@ -21,11 +25,6 @@ const Home = () => { const SocialButtonsData = socialBtnDataCreator(onOpen); - ReactGA.event({ - category: "pagevisit", - action: `Viewed Home Page`, - }); - return ( <> + +interface ImportMeta { + readonly env: Record; +}