View Full Version : count links visited

04-05-2010, 02:51 PM
I would like to have help with solving an issue.

I need to present users with a nxn matrix where each cell contains a
link. Participants can click on any link they want, number of times
they want, and in the order they want. I want to be able to keep
record of which links they click on and how many times they click on
each link. I want to have a separate count for each participants.

Best regards

04-06-2010, 04:38 AM
1. You can TRY to store the clicks in a cookie. You can then TRY to retrieve that on the next page. Repeat, add one each time, etc. Get a number in the end and do what you want with it. But this is not reliable because cookies are unstable-- they can be deleted or modified by the user if desired and also may not work on some systems or may be randomly deleted by browsers sometimes. Generally they're fine for a single visit to your website, but not 100%, more like 95%.

2. Cookies are stored on the user's computer. This means two things, one good and one bad:
1) The users will never overlap: the number will be stored in the same way for each user, one value per computer (actually, per browser), so that you will have a separate count for each user.
2) You cannot EVER get this information on the server and store it (email it to yourself, put it in a text file, store it, etc.). You can of course put this on the server in another way, but if you are doing that, then why not use serverside coding from the start to securely and reliably store all of this.

So, in conclusion, you can do this, but it's almost useless if you actually want to do anything with the information. If you want that, you need a serverside language, not Javascript (though you can use Javascript to add certain things to the page in addition to the serverside code).

If you want to continue, then I suggest googling "javascript cookie functions" and looking for a tutorial/example of how to use cookies in Javascript-- it's not that easy because they are not a default part of Javascript, but they can be used easily enough once you find some functions that work and that you like. THEN just store a cookie upon clicking a link and repeat by adding 1 each time. That's all...