My website is counting visitor views on certain pages. I noticed that Google and other Bots are clicking to my site like crazy and some of the pages get unrealistic view counts (compared to those produced by humans).I am asking for best practice to exclude those bots from my view counts. Obvious a simple user agent contains bot won't do it.I do not think there is a bullet prove solution nor I need one.Note: I am using PHP + MySQL.
What is the best way to exclude bots from view counts?
php;mysql;web crawlers;best practices
I'm glad you know there isn't going to be a bulletproof way to accomplish this. That means your outlook is at least realistic.Since JavaScript is not an option I would say you're left with:Check the user-agent for the word bot in it. That will catch most of them.Compile a list of known bots and filter them based on some kind of unique identifier, probably their user-agent.Put a hidden link in the footer of your website that links to a page that collects user-agents and/or IP addresses. Users won't see this but bots will. So anyone who visits that page will be a bot. Record them and then block them from your stats.