Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable DebugView in google analytics with react-ga4 [closed]

Edit: Restarting react fixed the issue, the following code works as expected.

I am trying to enable the DebugView mode in Google analytics but events are not being shown or are logging in any way. I am using react-ga4: https://www.npmjs.com/package/react-ga4 and it says here you can enable debug by passing in the config: https://support.google.com/analytics/answer/7201382?hl=en#zippy=%2Cglobal-site-tag-websites

I believe the following code should enable the DebugView mode in the google analytics:

ReactGA.initialize([
  {
    trackingId: "G-TRACKINGID",
    gaOptions: {
      debug_mode: true,
    },
    gtagOptions: {
      debug_mode: true,
    },
  },
]);

Then to trigger event I have the following code in an onClick handler:

ReactGA.event({
  action: "action_button",
  category: "category_button",
  label: "label_button",
  value: 44,
});
like image 809
Colin Hale Avatar asked Jul 30 '26 01:07

Colin Hale


1 Answers

This worked for me :

ReactGA.initialize("G-TRACKINGID", {
    gaOptions: {
      debug_mode: true,
    },
    gtagOptions: {
      debug_mode: true,
    },
  });
like image 199
user1742513 Avatar answered Aug 01 '26 16:08

user1742513