Click to See Complete Forum and Search --> : Advance Click Count


k0r54
12-14-2004, 01:34 PM
Hi,

I have a click count on my site but it is absolute crap. I am literatly just making it + 1 to a count field in a table everytime the page is loaded.

I really need a more advance one but im not sure how? Perhaps so that it can tell me how many different people and how many the same and so on and so forth without taking a big process time?


Any ideas on how to do this?


Thanks
Adam

ShrineDesigns
12-14-2004, 02:18 PM
that can be quite tricky, because you would have to capture the ip address of the visitor, which depending on their connection can change dramatically. from my own experience, the last part of the ip address is the most commonly changed (xxx.xxx.xxx.[xxx]), and the first part is the least commonly changed ([xxx].xxx.xxx.xxx), as for 56k and dsl (w/ dynamic ip address) the ip address can jump around quite a bit

k0r54
12-14-2004, 03:13 PM
yeah i know, that is difficuilt, how do web hosts do it as they do a click count.

Also surly but reading the ip address putting it into a database if it is not in there and if it is +1 to click count would do it. As i can just to SELECT DISTINCT.

Would something like that work, or would it be rediculous in resources. How do sites monitor there clicks.

k0r54
12-14-2004, 06:13 PM
I take it no1 ha any ideas?

NogDog
12-14-2004, 11:53 PM
Maybe too simple, but how about:
Create a data table with one column for IP addresses, make it the primary key for the table (varchar 15).
Whenever someone clicks into your site, grap their IP address and insert it into your database. MySQL will automatically reject it if it's already in there, so you get no duplicates.
When you want to report the total unique number of IPs that have "clicked in", just do a SELECT COUNT(*) FROM table_name;

k0r54
12-15-2004, 11:52 AM
Thanks

Its atleast more complex than my current one but how do big sites monitor the clicks and things?

I just want to know how many people really are viewing my site.

Hellspire
12-15-2004, 01:33 PM
If you only want to count unique visitors the most efficently would be to set a cookie that would have a random hash basically. uniqid() and store that in a simple table and the cookie as well.

I am at work so others will have to explain this method but here are the steps.

Check for existance of the specified cookie name. select from table where the id = the value of the cookie. if not found then delete the cookie and make a new id. (this should almost never EVER happen, and if it does you did something wrong with this if statement!). *

if no cookie then set cookie with the uniqid() insert that into database (unless another id exists in the database which will almost never happen, otherwise simply redeclare a new uniqid.... *duh* Then the cycle continues...


to count the users simply count the amount of id's in database.

* you get rid of old entries by adding a timestamp field. Then a cron which will delete all old entries over 5 minutes or whatever.

Enjoy....

eDIT: Also as an added bonus you can also store the exact page they are on at the moment.

The only disadvantage of this system is if they block cookies, however, not many do.

k0r54
12-16-2004, 11:27 AM
Hi,

That sounds brilliant but complex. How would i do that exactly do you have any code or anything. I really like the feature of knowing what pages they are clickin on.


Many Thanks
adam

k0r54
12-19-2004, 05:51 PM
Hi, any information on it ??

Thanks
Adam