react-ga4 icon indicating copy to clipboard operation
react-ga4 copied to clipboard

Not receiving any data to Google Analytics, debugger extension shows no information in console

Open olalonde opened this issue 3 years ago • 6 comments

I made the following wrapper component to enable google analytics in my react app. However it doesn't appear to work at all. Google Analytics isn't detecting any page views or anything. There is nothing in the Chrome inspector logs even when I activate the Google Analytics Debugger extension. What am I doing wrong?

import { useEffect } from "react";
import ReactGA from "react-ga4";
import { useLocation } from "react-router-dom";

ReactGA.initialize("G-__MYCODEHERE___", { debug: true });

export default function GoogleAnalytics({ children }) {
  const location = useLocation();
  useEffect(() => {
    const currentPath = location.pathname + location.search;
    ReactGA.send({ hitType: "pageview", page: currentPath });
  }, [location]);
  return <>{children}</>;
}

olalonde avatar May 16 '22 20:05 olalonde

I have same problem adding react-ga4 to my project. It's say sending to undefined.

ventsislavnikolov avatar May 24 '22 08:05 ventsislavnikolov

Also experiencing the same issue

BSalwiczek avatar Jun 08 '22 19:06 BSalwiczek

You need to install the Google Analytics Debugger Chrome Extension to see logs.

benfixit avatar Jun 21 '22 20:06 benfixit

There is nothing in the Chrome inspector logs even when I activate the Google Analytics Debugger extension.

olalonde avatar Jun 24 '22 02:06 olalonde

Experiencing same issue

lilypytel-toast avatar Nov 30 '22 14:11 lilypytel-toast

experiencing the same thing even after using the now maintained version: https://github.com/codler/react-ga4/

Michael-Xie avatar Apr 26 '23 14:04 Michael-Xie