I'm trying to set up Google Analytics on my React app but I can't get anything working.
I've followed the documentation and am running the following code included in my app.js:
import ReactGA from 'react-ga'
...
useEffect(() => {
ReactGA.initialize(process.env.REACT_APP_GOOGLE_ANALYTICS)
ReactGA.pageview('/')
ReactGA.pageview(window.location.pathname + window.location.search);
}, [])
(I've saved my Tracking ID into my .env file, which I copied from my analytics.google console)
I'm running my app from localhost:3000 but nothing is being sent via my network tab in developer tools in Chrome (I assume that's where you would see the data being sent back to Google Analytics). I've also tried following the "Demo Code" here: https://github.com/react-ga/react-ga
Nothing changes on my Google Analytics console and I don't see anything happening in my developer tools.
Can someone please tell me how to get started here?