I have been trying to make this work for a few days, and nothing is working. The events are simply not being captured no matter what I do.
I import ReactGA at the top
import ReactGA from "react-ga";
I initialize it after import
ReactGA.initialize("TRACKING-ID", {
debug: true
});
I create a function to handle the tracker
const GASignInHandler = name => {
ReactGA.event({
category: "Dashboard Home",
action: `User Signing In As ${name}`,
label: "Tracking users every time they sign in.",
nonInteraction: true
});
};
Inside my functional component called DashHome, and inside the return I call this. Pretty much if signedIn = true, run this function, if not run the console.log. This is for testing purposes obviously but I still don't see this event being logged in GA. It fires off in debug.
{signedIn ? GASignInHandler(userEmail) : console.log("signin not true")}
[react-ga] with fieldObject: {"hitType":"event","eventCategory":"Dashboard Home","eventAction":"User Signing in as My","eventLabel":"Tracking Users Every Time They Sign In.","nonInteraction":true} log.js:2 [react-ga] with trackers: undefined
I also have all the tags that GA told me to put into my public/index.html.