diff --git a/index.html b/index.html index 79c4ed12..7a0c2cbb 100644 --- a/index.html +++ b/index.html @@ -21,6 +21,18 @@ + + +
diff --git a/package.json b/package.json index a0b419de..185328a7 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "react-colorful": "^5.6.1", "react-dom": "^18.2.0", "react-error-boundary": "^4.0.10", - "react-ga4": "^2.1.0", "react-helmet-async": "^2.0.5", "react-i18next": "^13.2.2", "react-icons": "^5.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0b2d3fac..0723287e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -122,9 +122,6 @@ dependencies: react-error-boundary: specifier: ^4.0.10 version: 4.0.10(react@18.2.0) - react-ga4: - specifier: ^2.1.0 - version: 2.1.0 react-helmet-async: specifier: ^2.0.5 version: 2.0.5(react@18.2.0) @@ -10386,10 +10383,6 @@ packages: resolution: {integrity: sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==} dev: false - /react-ga4@2.1.0: - resolution: {integrity: sha512-ZKS7PGNFqqMd3PJ6+C2Jtz/o1iU9ggiy8Y8nUeksgVuvNISbmrQtJiZNvC/TjDsqD0QlU5Wkgs7i+w9+OjHhhQ==} - dev: false - /react-helmet-async@2.0.5(react@18.2.0): resolution: {integrity: sha512-rYUYHeus+i27MvFE+Jaa4WsyBKGkL6qVgbJvSBoX8mbsWoABJXdEO0bZyi0F6i+4f0NuIb8AvqPMj3iXFHkMwg==} peerDependencies: diff --git a/src/context/GA4.tsx b/src/context/GA4.tsx index a4ebb566..1ff8652b 100644 --- a/src/context/GA4.tsx +++ b/src/context/GA4.tsx @@ -1,6 +1,5 @@ import { createContext, useEffect } from 'react' import { useLocation } from 'react-router-dom' -import ReactGA from 'react-ga4' const GA4Context = createContext({}) @@ -12,17 +11,18 @@ interface GA4ProviderProps { export const GA4Provider = (props: GA4ProviderProps): JSX.Element => { const location = useLocation() - useEffect(() => { - ReactGA.initialize(props.tag) - }, []) - useEffect(() => { setTimeout(() => { - ReactGA.send({ - hitType: 'pageview', - page: location.pathname, - title: document.title - }) + const gtag = (window as any).gtag + if (typeof gtag === 'function') { + gtag('config', props.tag, { + // debug_mode: true, + page_path: location.pathname, + page_title: document.title + }) + } else { + console.error('gtag not found') + } }, 100) }, [location.pathname])