HaLo2FrEeEk Posted October 23, 2009 Share Posted October 23, 2009 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. Link to comment https://forums.phpfreaks.com/topic/178698-click-counter-to-ignore-traffic-from-search-bots/ Share on other sites More sharing options...
GKWelding Posted October 23, 2009 Share Posted October 23, 2009 code for your click counter might help? without seeing your code the below is just a suggestion. if(!eregi("Googlebot",$_SERVER['HTTP_USER_AGENT'])){ {code for doing count} } Link to comment https://forums.phpfreaks.com/topic/178698-click-counter-to-ignore-traffic-from-search-bots/#findComment-942710 Share on other sites More sharing options...
HaLo2FrEeEk Posted October 25, 2009 Author Share Posted October 25, 2009 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. Link to comment https://forums.phpfreaks.com/topic/178698-click-counter-to-ignore-traffic-from-search-bots/#findComment-944027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.