I am trying to enable google analytics with the help to react-ga
hook.
I folloed their docs on github, I don't know why I'm not getting any data and don't know how can I debug this. I've paste this ReactGA.initialize("G-NHW4EP16PN");
code on every page but still I'm not getting anything, and also Stream configurations in my Firebase app.
import ReactGA from "react-ga";
function App() {
useEffect(() => {
ReactGA.initialize("G-NHW4EP16PN");
ReactGA.pageview(window.location.pathname + window.location.search);
console.log(window.location.pathname);
}, []);
return (
<>
<Suspense fallback={<LoadingWait src={LoadImg} />}>
<Router>
<Sidebar />
<Switch>
<Route component={Overview} path="/" exact={true} />
<Route component={Work} path="/work" />
<Route component={Services} path="/services" />
<Route component={Contact} path="/contact" />
<Route component={PageNotFound} />
</Switch>
</Router>
</Suspense>
</>
);
}
export default App;
The initialize method takes a universal analytics gaTrackingID as its first parameter. You are sending it G-NHW4EP16PN, which not a universal analytics tracking id. I would check your account again you appear to be trying to send it a GA4 measurement id instead.
ReactGA.initialize('UA-000000-01', {
debug: true,
titleCase: false,
gaOptions: {
userId: 123
}
});