How to get the timespan a visitor stays on site before bouncing away?

Discussion in 'PHP' started by yangyang, Apr 29, 2008.

  1. #1
    Trying to build a cute little php site statistics script, now I'm stuck with getting the average visiting time on site.

    How to do that? I'm using JS badge.

    HTTP is stateless, if that is the case how the server knows when the visitor navigates away? JS onunload?
     
    yangyang, Apr 29, 2008 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ajax call onload + ajax call onunload?
     
    matthewrobertbell, Apr 30, 2008 IP
  3. yangyang

    yangyang Banned

    Messages:
    757
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Tried but it didn't work for me. It just doesn't call when unloading.
     
    yangyang, Apr 30, 2008 IP
  4. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You could try recording the first visit, then every subsequent visit, then look at when the last visit was, last visit - first visit = time on site.
     
    matthewrobertbell, May 1, 2008 IP