Learn business growth with Google Analytics 4 Forums Google Analytics 4 Managing Multiple Tracker Events in GA4 on a Single Page

  • Managing Multiple Tracker Events in GA4 on a Single Page

    Posted by Tran on 21 February 2023 at 9:17 pm

    Hey folks, let me piggyback on this here – a story I’m continuing

    So, here’s my tangle. I have a parent-website and a little widget. The widget’s got its spot on the stage. Both of them are being followed by a pair of these Google Analytics 4 trackers.

    The lemonade stand (that’s the widget) is mine and I’ve arranged it so it knows who it sends the info to (“TRACKER_ID”) when I’m setting up GA4. But I’m not sure the parent site’s got that kind of detail in the settings for gtag. And that’s throwing a bit of sand in the machine here because every time the parent hollers, the widget’s GA4 gets the echo, every little event. Sure, those noises can be sifted out on the reports in Google Analytics, but my client doesn’t want to mess with that. They’re more for a clean-cut, no-fuss kind of accounting. This makes me wonder – is there an early filter we can use before the chatter gets to the widget’s GA4. I’m already thinking about putting the widget in an iframe, but are there other escape routes?

    I tried to get a service worker onboard my widget react app, thinking I could flag down the fetch requests to Google Analytics, muffle them or boot them out. But turns out, these aren’t your regular fetch quests, but more like a ping maneuver for shooting the juicy bits to GA…

    relevant image

    Any ideas, compadres?

    Sebastian replied 10 months, 3 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Anh

    17 May 2023 at 7:09 am

    One potential solution is to differentiate the events that are sent to GA4 by the parent website and by the widget. Each event could have an associated “source” parameter indicating where it comes from. You can then use this parameter to filter out the irrelevant events on GA4 using the interface’s filter system. This way, the events that your client sees on GA4 would be the only ones relevant to them. Additionally, you could consider using Google Tag Manager. This tool allows you to control the behaviour of your codes and adjust as per the requirements. With Google Tag Manager, you could determine when and where your GA4 codes should fire, which would allow you to avoid unnecessary events from parent website.

  • Sebastian

    7 July 2023 at 8:23 pm

    From the sound of it, your best bet would probably be to add some code to your widget that checks the incoming HTTP Referer header and if it indicates the request is coming from the parent site just drop the GA event altogether. Alternatively, you could configure your GA4 settings to filter out any such events. If neither of these solution suits your needs, there may be more advanced methods of intercepting these requests using service workers, but that would likely involve implementing more complex functionality to check whether each fetch is relevant before deciding whether to let it through to GA4.

Log in to reply.