Once you've collected sufficient data, you'll be able to identify a threshold that separates legitimate users from bot traffic with confidence.
2. Use Cloudflare Bot Protection
If your website is protected by Cloudflare and the spam originates primarily from specific countries—as in our example with China and Singapore—you can create firewall rules that apply Bot Checks only to traffic coming from those locations.
This approach works well if you don't expect legitimate visitors from the affected countries.
Cloudflare also offers several additional bot protection features, including:
- Known Bots — blocks traffic from Cloudflare's database of known bots.
- Verified Bot Categories — allows you to block or allow verified bots based on their category.
3. Block Spam at the GTM Trigger Level
If you've identified specific characteristics shared by spam traffic, you can prevent those requests from being tracked in your web GTM container.
For example, you can exclude events based on:
- Referrer URL
- Screen resolution (for example, 0×0)
- Other request parameters that reliably identify spam traffic
Keep in mind that this approach only prevents future spam from being collected. It won't remove historical bot traffic that's already stored in GA4.
For existing data, you can apply report filters using available dimensions such as Country.