codler / react-ga4

React Google Analytics 4
https://www.npmjs.com/package/react-ga4
266 stars 34 forks source link

Missing events when send event to multiple trackers #51

Open dacsy opened 1 year ago

dacsy commented 1 year ago

Hi everyone I have a config multiple trackers, however when I try to send event to each tracker, it's missing events in the second tracker.

      ReactGA.initialize(tracker.trackingId);
      this.trackers.push({
        trackingId: tracker.trackingId,
      });
  trackers.forEach((tracker) => {
      ReactGA.event(`Checkout started`, params); // Custom event
      ReactGA.event(`view_item`, params); // GA4 event
      ....
  });

My first tracker work as expected. The second tracker are missing most of events. What am I missing in the configuration ?

JeremyGuinn commented 1 year ago

See this multiple products test as an example on how to initialize multiple products (i.e. trackers). There is also this example in the readme.