Published on

Blocking bottraffic or trafficbot url requests from jacking up your Google Analytics


I’m going to prefix this with the following: I am not a RegEx expert, I just screwed around for a bit on until something looked right.

This is what I came up with


My thought is, any request that starts with “bot” and ends with “traffic” (or visa versa) AND has a period with something after it. I don’t have a single URL on the site that should match those patterns, so I think this is solid, but any Regex Gurus could weigh in if they want @stevemcniven

Here’s the web.config IIS Rewrite rule, it’ll abort the request so your error pages won’t even render (with the GA scripts on them)

        <rule name="Block bottraffic routes" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="(bot.*traffic|traffic.*bot)[.a-z]+" />
             <add input="{URL}" pattern="((?=bot-?)|(?=traffic))[.a-z]+" />
          <action type="AbortRequest" />

Boost your online presence.

Let us create the perfect digital experience for your company.

Contact us now