send GA pageviews only if initialized

This commit is contained in:
Athou
2023-05-17 13:43:25 +02:00
parent 2979600cc2
commit e90b80c641

View File

@@ -122,7 +122,7 @@ function GoogleAnalyticsHandler() {
}, [googleAnalyticsCode])
useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname })
if (ReactGA.isInitialized) ReactGA.send({ hitType: "pageview", page: location.pathname })
}, [location])
return null