Learn business growth with Google Analytics 4 Forums Google Analytics 4 Sending an event to a specific tracker when using react-ga4 with multiple trackers

  • Sending an event to a specific tracker when using react-ga4 with multiple trackers

    Posted by Gabriel on 4 October 2022 at 2:42 pm

    Hey there, in my code I have 2 trackers set up, one with ‘G-0000001’ and another with ‘G-0000002’. Now, there’s this event ‘timeToLoad’ that I want to send exclusively to the first tracker ‘G-0000001’. Any pointers on how I could do that?

    Daniel replied 1 year, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Daniel

    Member
    5 October 2022 at 6:34 pm

    You can send a specific event to one particular tracker by referencing the tracker name directly when you send the event. For your case, you can first give your trackers names when you create them. For example, ‘tracker1’ to the ‘G-0000001’ and ‘tracker2’ to the ‘G-0000002’. Then, in the command to send the event ‘timeToLoad’, reference it to ‘tracker1’ will send this event exclusively to the first tracker with the ID ‘G-0000001’. An example code might look like this: ga(‘tracker1.send’, ‘event’, { eventCategory: ‘category’, eventAction: ‘timeToLoad’}).

  • Daniel

    Member
    4 February 2023 at 3:44 pm

    Sure thing, you can just specify the name of the tracker you want to send the event to. When you create the tracker, assign it a name. Then, when sending the event ‘timeToLoad’, simply add the tracker name before sending the event like this: ga('trackerName.send', 'event', 'timeToLoad'). This tells GA to send the event to ‘G-0000001’ only.

Log in to reply.