 <p>My way of doing this is simple:</p> <ul> <li>When a user loads a page, their "last page load time" is updated in the database.</li> <li>A cron script runs every minute. It looks for users whose "last page load time" was in the last minute.</li> <li>Increment the "time spent on site" for each user found.</li> </ul> <p>In this way, I can keep track of users accurately to the minute. Just divide by 60 to get the hours.</p>