Google Analytics 4 with React: No data received in past 48 hours

Viewed 1131

I'm trying to get Google Analytics 4 to work with my Create React App but I'm just not having any luck.

I have:

  • Created a Google Analytics 4 Property
  • Created a web stream
  • Tried turning on and off enhanced measurements

To implement analytics in my app I tried with the default script tag:

<Helmet>
  <script async src="https://www.googletagmanager.com/gtag/js?id=G-6442DC018S"/>
  <script>
    {`window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', 'G-6442DC018S');`}
  </script>
</Helmet>

This loaded correctly, no errors in my console, I can see the network tab correctly loads the script.

But Google Analytics still shows: enter image description here

So I tried using the ga-4-react package:

  let ga4react;

  if (!GA4React.isInitialized() && MEASUREMENT_ID) {
    ga4react = new GA4React(MEASUREMENT_ID);

    ga4react.initialize().then(
      (ga4) => {
        console.log('success')
        ga4.pageview(window.location.pathname);
      },
      (err) => {
        console.error(err);
      }
    );
  }

Once again, no errors in the console, I see the success string (so I assume everything went well.

But unfortunately there's still no data being sent to Analytics.

Any idea what could be happening?

EDIT: I've tried setting up a Google Tag Manager and thanks to the preview mode I can verify data is being set to Google Analytics, however none of it is appearing in GA.

enter image description here

0 Answers
Related