Got Bots? We got an App for that!

triggers

#1

I was recently talking with a customer that wanted to track the amount of Bot traffic that was hitting his customer-facing website. The Bots he was interested in had a user agent containing “Googlebot”, so it was very easy to write a trigger to track these hits differently than the “legitimate” customer hits, but he also wanted other stats like volume, URIs, etc.

I started to look into the API to see how hard it would be to setup counters for bytes in and out, URIs, clients, etc…then I realized. This could all be done with just a few line of trigger code to put all Bot traffic into an application!

To get userAgent, you need to start on the HTTP_REQUEST side:

if (HTTP.userAgent.indexOf(“Googlebot”) >-1){

Flow.store.GBuserAgent = HTTP.userAgent;

}

Then add it to the App on the HTTP_RESPONSE side:

if (Flow.store.GBuserAgent.indexOf(“Googlebot”)>-1){

var app = “GoogleBotTraffic”;

Application(app).commit();

}