this is my first time trying to integrate google analytics for my webpage. I’ve followed a recent youtube tutorial that integrates this with a react app, although it does not seem to work.
Code I used:
const TRACKING_ID = "My Tracking Code";
ReactGA.initialize(TRACKING_ID);
const App = () => {
useEffect(() => {
ReactGA.send({
hitType: "pageview",
page: window.location.pathname + window.location.search,
title: "Home Page",
});
}, [])
return (
<BrowserRouter>
<Routes>
<Route path='/' element={<Layout />}/>
</Routes>
</BrowserRouter>
);
}
Does anyone see what might be wrong?