Forum Moderators: coopster

Message Too Old, No Replies

Exclude bots

         

Sandro87

2:00 pm on Jun 20, 2009 (gmt 0)

10+ Year Member



Hello,
I want to count visits to a page, how can I exclude bots and other things like that? For example if there's ads from adsense when I visit the page 2 visits are counted.
What condition can I use? Browser used?

rainborick

7:37 pm on Jun 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I actually do this with a Perl script, but you can do it in PHP just as easily. I call a counting script on my pages with an <IMG> tag and embed the file name in a query string, but I put the counting script in a directory that is blocked by my robots.txt file. That way search engine visits don't get counted. It also suppresses extra counts when users reload a page or use the <BACK> button because the "image" has been cached by the browser.

If you use this method, once the counting has been done you can either have the script generate an image for the browser to render, or simply redirect to an actual image file. I'd suggest a redirect because it is faster.