Results 1 to 2 of 2

Thread: count links visited

  1. #1
    Join Date
    Apr 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default count links visited

    Hello,
    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

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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...
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •