Jump to content

Click counter to ignore traffic from search bots


HaLo2FrEeEk

Recommended Posts

I have a click counter on my site that...well, counts the number of clicks a link gets on the frontpage.  It's a good system, but it's got a few flaws, an example being that it counts "clicks" from search engines and crawlers.  Since the most common of these is Google, I'd like to start by ignoring clicks from Googlebot.  I still want to redirect the bot like normal, I just don't want to count it's access of the click counter URL.  How could I go about doing that?  I'm having a hard time figuring out what Useragent or IP range Google uses.

My bad, I actually figured it out shortly after posting this.  Basically I just made an array of useragent strings from common search engines and crawlers, then did something like this:

 

$query = (in_array($useragent, $disallow)) ? "" : "[query for +1 click]";
mysql_query($query);

 

It works, and I can add new useragents to the array any time I want, which helps make it versatile.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.