Link to home
Start Free TrialLog in
Avatar of svsvsv4
svsvsv4

asked on

count unique clicks

i have a site with links, i want to count unique clicks, i use cookies like

"linkcookie.$var"

is this the best way?
Avatar of minichicken
minichicken

Do you mean counting unique clicks of the link of the whole site,
And see how many users has clicked that particular link?

So basically, counting unique visitors of a particular page?
Avatar of svsvsv4

ASKER

no, i need to have restriction of times user clicks, i mean, that if someone clicks, the cookie will count only 1 time,
if he clicks again, it won't count....
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of svsvsv4

ASKER

yes, it's the best way, but i have about 400 links, and average user hits about 20-50 each time, i use as i said a cookie:

cookie.$id

which creates a cookie with name like "cookie.300"
so i check it later, by id of the link,
i noticed that some times it's not the best, maybe because the cokies are disabled with that user?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also if you was tracking induvidual unique clicks for induvidual links you would of course have to go one step further, prehaps storing page id's in the cookie - and only adding to this series of id's if it is not already present (using a combination of explode, implde and in_array checks). You would then have to reference this against a database table to track specifically what links where clicked but, its not going to be a pretty method when handling users that are just casual browsers and are not logged in.
Usually the thing you care about is how many requests have been recorded at the server for the page in question. Because that is the only thing that ensures that you are counting REAL communication.

However it is possible to modify the values of cookies via client-side JavaScript so if you're writing a game etc, and client-side clicks need to be counted regardless of serverside communication, then you could set the cookie to increment in value each time a link is clicked, and then whenever server communication occurs that cookie value would be sent up to the server.

JP
Why don't you just save the IP address using $_SERVER["remote_addr"] along with datetime. Once this is saved you can determine when they clicked it last? This would be pretty reliable except for dial-up users, which would have to disconnect and reconnect to be able to bypass the system?
physco
Using IP is a very bad thing as a lot of users (e.g. AOL) are passed through a proxy and will have the same IP. THis also counts for employees of large firms that also have to use a proxy.