Every time you request a Web page – by clicking a link, accessing a saved bookmark, or entering a URL directly into the address bar – your browser records a timestamp, precise to a one-second increment.
It’s important to note that, technically, the browser does not record a timestamp when you leave the page. It does record a new timestamp for your next page request, but that timestamp is associated only with the page you’re accessing, whether or not it’s part of the same website, and not the page you’re exiting.
What this means is that Google Analytics can calculate Average Time on Page and Average Visit Duration based only on the difference between timestamps for successive page requests on your site.
Average Time on Page is calculated as the average difference between the request timestamp for that page and the request timestamp for the next pageview that occurred within your site. If only a single page is viewed during a visit, that pageview does not figure into Average Time on Page, since there is no second timestamp to subtract from.
Similarly, Average Visit Duration is calculated based on the timestamp difference between the first and final pageviews that occurred during a visit. Since the duration of the final pageview cannot be calculated, Average Visit Duration as reported in GA is always somewhat shorter than in actuality.
In an upcoming post, we’ll review the implications of timestamp-based metrics for a website, such as a blog, that normally experiences a high proportion of single-page visits.