How to exclude staging website traffic ( from GA4?

I followed the steps in this webflow blog post to set up google tags and google analytics, however, the steps to filter out (exclude) staging site traffic don’t seem possible in GA4. The only filtering option I can find is by IP address to exclude internal user traffic. Is there a way to exclude traffic by URL to filter out the traffic? There IS a way to exclude referral sites by URL in GA4, but I’m guessing that does not apply to this situation.

Thank You!

I’m pretty sure you have to add a stream for your url specifically, and then mark it as Test Data so that it can be filtered out.

Thank you Michael, I will try this.

I also tried just blocking my IP address (as GA4 documentation recommends), and even though it’s blocked, I can see that when I visit the website, it is still counting my visits and interactions…

Hi Michael, as a GA noob, do you mind sharing how exactly to do this? :sweat_smile: I’ve tried to for solve this over many years but Google Analytics is so confusing for me. Any advice or links to share are welcome!

@joemoewin @szollar

For excluding traffic, here’s how I do it.
For IP traffic, I haven’t found an easy-to-implement solution that I like for GA4.

1 Like

Thanks so much! Hugely helpful, appreciate it.

I discovered the absence of a direct mechanism to filter out traffic from the staging site based on the source URL – a feature seemingly taken for granted in the classic Universal Analytics era. The conventional approach of excluding by IP address falls short in this context. Eager to find a creative solution, I’ve dabbled in nuances and delved into the depths of Google Tag Manager.

1 Like

“Exclude staging website traffic in GA4 by implementing a view filter with the condition ‘Hostname does not contain’ and specifying the staging domain. Additionally, use IP address exclusion to further ensure accurate analytics by filtering out internal traffic during development and testing.”

Hi Michael,

Petr here again :slight_smile: First thank you very much for the video guide you put together.

It helped me a lot to setup the filter. But after testing via Tag Manager Assistance tool I found out the filter doesn’t work as expected - it still fires and sends events into GA.

My setup - Trigger:

My setup - Tag:

I did double check all the settings… there is not much to do wrong.

The debug shows this:

As you can see the Blocking trigger si set up, but do not apply (??) because the second filter is invalid due to _event value mismatch.

Do you have any idea why is this happening? Different event type?

Thanks for you help and have a great day


OK I have found a fix. If anybody runs into this issue, make sure the Trigger type match firing triggers in the tag config.

My firing trigger is “Initialization - All pages”, as recommended in the official docs:

This DOESN’T work with the video, where a trigger type for filtering is “Page View”. For me the correct was “Initialization”.

Now it works as expected.


Hope this helps someone.


1 Like