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

args.category AND args.action are required in event()

Open MrFarhan opened this issue 1 year ago • 1 comments
trafficstars

I have followed the documentation and added following code:

    ReactGA.event({
      category: 'Page Visit',
      label: `Employeer Name: ${localStorage.getItem("username")} visited ${window.location.pathname} `,
      action:"",
      nonInteraction:true
    });

But is is throwing following error:

args.category AND args.action are required in event()

I have also initialized react GA in app.js ReactGA.initialize('G-mymeasurmentid');

MrFarhan avatar Dec 01 '23 15:12 MrFarhan

You need to set the action attribute to something else than ""

    ReactGA.event({
      category: 'Page Visit',
      label: `Employeer Name: ${localStorage.getItem("username")} visited ${window.location.pathname} `,
      action:"Action Name", // <- this is missing
      nonInteraction:true
    });

ospaarmann avatar Jan 18 '24 11:01 ospaarmann