Page 1 of 1

small click tracking script

Posted: Thu Apr 17, 2008 1:44 pm
by desius
I'm trying to work on a small tracking component for something. I'm moving quite along, but I need some help in regards on how to avoid counting bots (I only want to count human visitors). Anyone have any tips? Everything I've researched has driven me to 20 or so completely different solutions and I'm not sure which way to go.
  • My plan right now is to filter out all known/trusted bots that I can with php's $_SERVER['HTTP_USER_AGENT']
    After thats done, I plan to set a cookie that expires every 30 seconds to a minute or so.
    Then I'll test for that cookie, if(!$cookie){return true;}
    Then, not sure if this is possible: can I use $_SERVER(['HTTP_ACCEPT']) to verify that the user can download images?

Can anyone give me some tips/advice on any of this? Should I add some sort of timing mechanism that checks to make sure the user isn't surfing at inhuman speeds? is that necessary?

Re: small click tracking script

Posted: Fri Apr 18, 2008 2:52 pm
by samb0057
You can't just test if the cookie exists, what about the user's first page visit?

I would recommend storing each hit in the database using an ip. every time a hit comes in, check the db to make sure they havent hit more than X times in the last N minutes. if they hit 20 times in 5 seconds or something else like that, deny access.

This is a hard one though as there is no fool proof solution.

Re: small click tracking script

Posted: Fri Apr 18, 2008 4:53 pm
by desius
I'm logging the first visit fine using the method I mentioned. I set the cookie before I log the tracking and it's working like I'd hoped. My only problem now I am discussing in this thread:
viewtopic.php?f=1&t=81565