small click tracking script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
desius
Forum Newbie
Posts: 9
Joined: Thu Apr 17, 2008 1:38 pm

small click tracking script

Post 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?
samb0057
Forum Commoner
Posts: 27
Joined: Wed Mar 26, 2008 9:51 am

Re: small click tracking script

Post 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.
desius
Forum Newbie
Posts: 9
Joined: Thu Apr 17, 2008 1:38 pm

Re: small click tracking script

Post 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
Post Reply