Results 1 to 3 of 3

Thread: Youtube Hits Counter

  1. #1
    Join Date
    Jul 2006

    Youtube Hits Counter

    Hi, i am in the middle of developing a website, and i would like to add a function to my site whereby a member can see how many times their profile page has been viewed, similar to the way YouTube displays the amount of hits a video has.

    I have a few questions which i hope you can help me with:

    A - who does the YouTube counter work OR what is the best way to build these counters... are they (1) - IP based, (2) - Cookie based OR (3) - another method

    B - does the page make a database update each time a unique user lands on a video page

    C - how often is the number updated... for instance, if i view a video on youtube on several different devices all connected to different networks, the number does not update immediately... so how does it work

    Thanks in advance to anyone who can offer any help here

  2. #2
    Join Date
    Aug 2006
    this one is a bit too vague, you can use ip, cookies, sessions, or if everyone must be logged in to use the site usernames would be best.

    here's the problem, ip's change if i use several devices or locations i'll have different ip's each time, and some people use dial up and always get new ips. cookies are good too but can be deleted by the end user, and still if i login from 2 devices it will count me twice, sessions also have the same problem if i use several devices then i'll have several sessions, but username never changes - no matter where i login from i'll be using the same username - but ofcourse i may have several usernames.

    so it's really hard, you'd probably have to use unique ips in a 24 hour period along with cookies - so first check for a cookie, if no cookie then they are unique or just logging in again from a second device, if the same ip returns then you know they were already counted, so you'd have to place cookies on their device and record ips on your server and compare the two - so something like...

    if( is_IP_Unique() && is_cookie_missing() ){
    increase counter();

    i.e. check if the cookie is missing and that the ip has not been logged yet,
    and only if both checks pass they are unique and in that case you want to increment the counter and set a cookie and log the ip.

    it all depends on how unique you want the visitor to be, you could even keep the ip log permanently if you only want to count unique ips, but you 'd have to dump it every month or few months so it does not get too big

  3. #3
    Join Date
    Jul 2006
    Cool, thanks for your help, much appreciated...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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