Page 1 of 1
IP Addresses : A better understanding..
Posted: Thu Nov 05, 2009 9:28 am
by Kev
I'm coding a "click counter" jump script in PHP and wish to prevent counting of "double clicks" or people that click one link a whole bunch of times in a short period.
One way I was thinking to achieve this was by seeing if that particular visitor's IP address had clicked on the same link earlier (within like a 2-minute window).
My question is...
Can two web surfers on the Internet share the same IP Address? I'd hate to not count a click because someone who clicked a link for the first time has the same IP address as someone else they don't know who clicked a couple seconds before.
Any suggestions or guidance on this? Thanks.
Re: IP Addresses : A better understanding..
Posted: Thu Nov 05, 2009 9:40 am
by AbraCadaver
Many users share an IP address, especially if they are behind a router or proxy such as at work, at school or even at home behind a linsys/dlink router, etc.
There is no fool-proof way to accomplish this, but in general I would probably set a cookie. Check if cookie is set, if not, record the click and set the cookie. If set, don't record the click. This will work if the user accepts cookies and if they don't clear their cookies. If you want it timed, then you can insert the time in the cookie.
Like I said, there's really no guaranteed way of doing this.
-Shawn
Re: IP Addresses : A better understanding..
Posted: Thu Nov 05, 2009 10:25 am
by volomike
Within a two minute window, odds are pretty good that no two people will have an IP address at the same time.
Now, if the window is larger, say, 1 hour, the odds get worse against you.
That's why I combine $_SERVER['HTTP_USER_AGENT'] and $_SERVER['REMOTE_ADDR'] in a table (two columns), cached up to 1 day, to try and increase the odds of uniqueness. It's not perfect, but it's better than nothing. You can also combine with a cookie that you drop and check, or session variables.
And any time you can reduce that cache to under an hour -- if that will work in the context of your site -- then I suggest that. In some contexts, however, that's not suitable and you may need an hour, a couple hours, a day, etc., depending on what you want to do.
Re: IP Addresses : A better understanding..
Posted: Fri Nov 06, 2009 6:41 am
by josh
There was this guy who I traded traffic with that claimed to have access to a "top 100 alexa site". He would, upon our request, send us 10s of thousands of hits in a very short window, so much it would crash our web server. What we think he was doing was using a proxy list or sending forged TCP/IP packets because all the traffic would hit one page and we would have 0 requests for our javascript or image files. That is one way to thwart it, but as far as proxies you're pretty much out of luck too. No reliable ways to detect them.
The best thing to do is keep track of the bounce rates of said clicks, if the bounce rate is high or close to 100% you're getting forced or bad traffic (example someone embeds your referral link as a hidden iframe on some random websites)