Filtering bot and spam traffic out of GA4
Suspicious spikes from odd referrers? A conversion rate that looks worse than reality? Bot and spam traffic may be polluting your GA4. It filters some automatically — but not all, and the rest is on you.
GA4 automatically filters traffic from known bots and spiders using the IAB list, and that handles the well-behaved majority. What it does not catch is your own team, your staging environment, headless-browser scrapers, uptime monitors, and referral spam that never touches your site at all. Those inflate sessions, deflate conversion rate, and — worst of all — teach your ad platforms to optimise toward traffic that will never buy anything.
What GA4 filters for you
Automatic bot exclusion is on by default and cannot be turned off. It matches against the IAB/ABC International Spiders and Bots List — Googlebot, Bingbot, and the large catalogue of identified crawlers.
This handles most search-engine crawling and a good share of commercial crawlers. It does nothing about the four categories below, which is where the noise in a typical property comes from.
The four kinds of traffic GA4 will not catch
1. Your own team
Internal traffic is the largest source of pollution on most low-to-mid-traffic sites. Your developers reloading a product page forty times, your support team walking a customer through checkout, your agency QA-ing a campaign.
On a site with a few hundred sessions a day, this is not noise — it is a visible fraction of your data, and it looks exactly like engaged behaviour.
2. Staging and preview environments
If your staging site carries the same measurement ID as production — which happens constantly, because the tag lives in a template that gets copied — every deploy test lands in your production property.
The fingerprint is a hostname that is not your production domain.
3. Headless and automated browsers
Scrapers, price-monitoring bots, security scanners, uptime monitors, and synthetic testing tools. Many run real browsers, execute JavaScript, and fire your tags exactly like a person would. The IAB list does not know about them.
4. Referral spam
Traffic that never visited your site at all, injected directly via the Measurement Protocol by spammers hoping you will visit the referring domain out of curiosity. It shows as referrals from domains you have never heard of, often with a 100% bounce rate and one-second sessions.
Why this matters more than it looks
Beyond the obvious reporting distortion:
- Conversion rate is understated, because bot sessions never convert. Every optimisation decision you make is measured against a diluted denominator.
- Audiences get polluted. Remarketing lists built on "visited the product page" fill with crawlers.
- Ad platforms learn the wrong lesson. If bot-heavy traffic feeds back into optimisation signals, you are paying for the algorithm to find more of it.
- Engagement metrics distort in both directions — bots either bounce instantly or hammer pages, and both skew averages.
The fixes, in order of value
1. Define internal traffic, then filter it
In GA4: Admin → Data streams → your stream → Configure tag settings → Define internal traffic. Add your office IP ranges and your team's home IPs where practical. This sets a traffic_type parameter of internal on those hits.
Then: Admin → Data settings → Data filters, and create an Internal Traffic filter.
Two things people get wrong here:
- The filter starts in Testing mode. In testing it marks traffic without excluding it, which is genuinely useful for a week — verify the volume looks right — but it does nothing until you set it to Active.
- Filters are not retroactive. Once active, they exclude permanently and the data is gone, which is the correct trade-off but worth knowing before you flip it.
For remote teams where IPs are unstable, a better approach is often a cookie or a persistent flag set on an internal-only URL, mapped to the traffic_type parameter.
2. Exclude non-production hostnames
The cleanest fix is to not send staging data at all — use a separate measurement ID per environment, injected by build configuration rather than hardcoded in a template.
Where that is not possible, GA4's Developer Traffic filter and a hostname condition catch the rest. Whichever route you take, verify by checking the hostname dimension for anything that is not your production domain.
3. Handle headless browsers at the tag level
Headless traffic is best filtered before collection, in your tag configuration, using a condition on the user agent or automation flags. A trigger exception in GTM is simple and effective:
// Blocking condition on your tags
navigator.webdriver === true
This is not bulletproof — determined scrapers spoof it — but it removes the honest tooling (monitors, testing frameworks, most scrapers) that makes up the bulk of the volume.
Do exclude your own synthetic journeys and uptime monitors deliberately, or your monitoring will pollute the data it is meant to protect.
4. Deal with referral spam
Because Measurement Protocol spam never touches your site, tag-level filtering cannot stop it. Options:
- Rotate your API secret if spam is arriving through a leaked one.
- Filter it in reporting by excluding the offending referrers in explorations or in BigQuery.
- Ignore it if the volume is small — spam bursts are usually short-lived.
Verifying you got it right
- Compare sessions before and after the filter goes active. A large drop means you were filtering real people — check the IP ranges.
- Check the hostname dimension for non-production values.
- Watch conversion rate. It should tick up after removing bot traffic, because the denominator shrank.
- Sample the remaining suspicious sessions — one-second sessions with no engagement, from unfamiliar referrers.
FAQ
Does GA4 filter bots automatically?
Yes, against the IAB known-bots list, and it cannot be disabled. It does not catch internal traffic, staging environments, headless browsers, or Measurement Protocol spam.
Are GA4 data filters retroactive?
No. Once a filter is active it excludes traffic from that point forward; historical data is unchanged. Use Testing mode first to confirm the filter matches what you expect before activating.
How do I exclude my own team from GA4 without static IPs?
Set a persistent flag — a cookie set from an internal-only URL, or a browser extension for the team — and map it to the traffic_type parameter instead of relying on IP ranges.
Why does my staging site appear in my GA4 data?
Because it carries the same measurement ID as production, usually because the tag is hardcoded in a shared template. Use a per-environment measurement ID injected by build configuration.
Will filtering bot traffic reduce my conversions?
No — bots do not convert. Removing them reduces sessions while conversions stay flat, so your conversion rate goes up. If conversions fall too, you filtered real users.
Check what is loading on your production site — and whether staging is quietly sharing its measurement ID — with the free tracking audit.
See where your tracking stands
Run the same 13-check audit referenced in this post against any URL. No signup, results in seconds.