lostdreamer - 8:47 am on Jun 24, 2011 (gmt 0)
... so there is no way YOU can calculate how long the user was on YOUR site. ...
It is possible (don't know if it's allowed by Goog).
In the onunload event you simply make sure this counter is sent through an ajax call to a special script on the website which records the time you had your focus on site, and the full url of the page you where at.
Simple and very effective.