Accurately and securely measure the time spent viewing a web page

Posted by balpha on Stack Overflow See other posts from Stack Overflow or by balpha
Published on 2010-03-27T09:08:57Z Indexed on 2010/03/27 9:13 UTC
Read the original article Hit count: 209

Filed under:
|
|

Suppose the following: You have a web page that presents a simple game to a user (e.g. a quiz, a puzzle, etc). The user solves the puzzle, submits the result, and you want to measure as precisely as possible how long they took to solve it. Assume it's quite simple, so we're talking seconds, not hours. Also assume JavaScript is required anyway, so there's no need to think of JS-disabled browsers. Finally, assume we don't want to use anything like Flash, Silverlight, or the like.

I can think of several techniques:

  1. Simply take the time between the points when the data was sent from the server and when the submission arrives. Since this is exclusively server-side, there's no chance for cheating. However, issues like network latency and page rendering time might make this unfair for users with slow computers / browsers / internet connections.
  2. On the first request, just send the page without the actual game data. When everything is loaded so far, retrieve the game data through an AJAX call and populate it into the page. This is similar to 1., but reduces some of the caveats introduced through time spent on overhead.
  3. Have the time measured on the client side using JavaScript and submitted alongside with the solution. This would theoretically be the most accurate, but it introduces the possibility of cheating, because you're relying on client data.
  4. Use the request time headers of a "ready to play" AJAX call and the result submission request. Same caveat as 3., as it is still client data.
  5. A combination of server side and client side measuring with some kind of plausibility analysis. I can't think of a good way, but maybe you can.

Thoughts? Other ideas?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about http