2

I get this error:

Command ignored. Unknown target: undefined

...when trying to trigger an event like this

ReactGA.event({
  category: 'Navigation',
  action: 'Clicked main CTA',
})

What does that mean?

I have initialised it like this:

ReactGA.initialize(process.env.REACT_APP_UA_ID, {
  debug: true,
})

And pageviews work:

ReactGA.pageview(window.location.pathname + window.location.search)
zok
  • 6,065
  • 10
  • 43
  • 65

1 Answers1

-1

Prior to firing ReactGA.pageview(), try firing ReactGA.set(). Initializing GA when your app loads should look along the lines of this;

ReactGA.initialize({ 'ID', {
  debug: true,
  }
})

ReactGA.set({ page: window.location.pathname + window.location.search });
ReactGA.pageview(window.location.pathname + window.location.search);
user10750437
  • 385
  • 4
  • 10