Presuming I've a wide open source web server or proxy I'm able to enhance, let us say apache or squid.
It is possible to way to look for the time each client stays on the web site?
HTTP is obviously stateless, therefore it is not trivial, but maybe someone comes with an idea regarding how to approach this issue?
I kind of question the reason why you want this anyway. What if an individual compares the web site for 3 seconds, will get distracted by another tab/window but leaves your page open for just two hrs? The solution you receive is 2 hrs, the solution you (most likely) want is 3 seconds.
With Apache or Squid you hardly can identify time a person stays in your page.
However with some additional sugar in your web page you are able to:
- Try Google Statistics.
It's free and it has a lot of functions.
But you will also invite Google to look at the stats of the site ... (but maybe that can help these to determine if you wanna buy you :-))
You can count time between once the page was asked for to once the next page is asked for, however this could simply be correct when the user remained on that page the entire time til he asked for the following page. Even so he might be around the original page (e.g. he opened up the brand new one out of a tab), and can only work when they do browse to a different page.
Also, only a thought, If you won't want to ping the server an excessive amount of, you can keep stuff buffered in memory, and just send towards the server whenever you got an adequate amount of data, or before the page closed.