Skip to main content

Stop Referral Spam Cold

Free Bot Detection Script for Google Tag Manager

Download the script

Block fake sessions and clean up your GA4 attribution data, no guesswork, no sign-up.

Even solid tracking setups can leak. Bots, fake referrals, and spam traffic distort your data and throw off your campaigns.

That’s why we’re giving away a free custom JavaScript snippet you can drop into your GTM container. It detects referral spam, blocks bot sessions, and protects your reports—all without slowing down your site.

Why Use It?

  • Filters fake referral traffic before it hits your GA4 reports
  • Compatible with server-side and client-side tracking setups
  • Lightweight, fast, and battle-tested in real client environments
  • No email form. Just copy & paste it into your setup

How to Use It?

  • Open your GTM container
  • Add a Custom JavaScript Variable
  • Paste the script (you’ll find it below)
  • Create a Custom Trigger that fires only when the variable returns “true”
  • Add the trigger as an Exclusion on your GA4 and leadgen tags
  • Test it using Tag Assistant by adding UTM parameters to your site URL (e.g. ?utm_source=spam.io)

Copy the Script

Below you’ll find the exact JavaScript you need. It’s plug-and-play.

Just paste it into your GTM setup and go!

Download the script

Bonus Tip

Update your list of known bot domains every quarter to stay protected. Not sure how? We’re here to help.

Trusted by Data-Driven Brands

[trustindex no-registration=google]
Subscribe Now

    Subscribe to our newsletter to receive news & updates. We promise to not spam you, super promise!

    Privacy Preference Center