react-ga4
react-ga4 copied to clipboard
args.category AND args.action are required in event()
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');
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
});