views:

120

answers:

6

Hello!

I would like to measure how much time a user spends on my website. It's needed for a community site where you can say: "User X has been spending 1397 minutes here."

After reading some documents about this, I know that there is no perfect way to achieve this. You can't measure the exact time. But I'm looking for an approach which gives a good approximation.

How could you do this? My ideas: 1) Adding 30 seconds to the online time counter on every page view. 2) On every page view, save the current timestamp. On the next view, add the difference between the saved timestamp and the current timestamp to the online time counter.

I use PHP and MySQL if this does matter.

I hope you can help me. Thanks in advance!

A: 

I think client side JavaScript analytics is the solution for this.

You have the google analitycs, piwik, and there also commercials tools in JS that do exactly that.

Am
+2  A: 

Why not just measure what actually can be measured?: referrals, page views, click-throughs, etc.

Collecting and advertising these kinds of numbers is completely in line with the rest of the world of web metrics.

Besides—if someone were to bring up a web page and then, say, go on a two week holiday, how best to account for it?

wallyk
You're right, I should rather measure these values.
+5  A: 

This is probably pointless.... what if the user has three tabs open and is "visiting" your site while actually working on the other two tabs? Do you want to count that?

Jim Garrison
@Jim, i think with javscript you can distinguish when the user is actually viewing the page, no?
Am
Thanks, this would really be a problem ...
+2  A: 

What you could do is check if a user is active on the page and then send an ajax request to your server every X seconds (would 60 secs be fine?) that a user is active or not on the page.

Then you can use the second method you have mentioned to calculate the time difference between two 'active' timestamps that are not separated by more than one or two intervals. Adding these would give the time spent by the user on your site.

vsr
Thank you, this would be a good solution I think. :)
A: 

google analytics includes a very powerful event logging/tracking mechanism you can customize and tap into get really good measurements of user behavior - I'd look into that

Scott Evernden
+1  A: 

Two factors are working against you -

  1. You can only collect point-in-time statistics (page views), and there's no reasonable way to detect what happened between those points;

  2. Even then, you'd be counting browser window time, not user time; users can easily have multiple tabs open on multiple browser instances simultaneously.

I suspect your best approximation is attributing some average amount of attention time per click and then multiplying. But then you might just as well measure clicks.

le dorfier
Thanks, perfect answer. :) You've persuaded me of choosing other metrics.