Determine how much time a visitor spent on a webpage

Not open for further replies.
I know that the way things are now Statcounter cannot report on how long a person has visited a page on my website when it is the last page visited or when the page is closed.

However, does anyone know of a way, or some code that can be added to my website pages, so that it can be determined how long someone visited a page before they closed the page or left my website?

Can anyone help me with this or direct me to a site that might be able to help?


Car Guy

Super Moderator
Once the page has been loaded in the browser their is no more activity that happens that can indicate how long the visitor viewed that page. I could load one page of your site and then leave for the day, or I could just close it as soon as the page has loaded. The browser does not send information back to your site about closing or leaving your page.

The only way to determine visitor length of visit is by having 2 or more page loads.

More about this here:
Thanks for the quick Reply. I know that Statcounter does not have a way to determine how long someone stays on the last webpage viewed. By starting a thread here I was hoping that someone might know of another way, or some code that could be added to my webpages to make such a determination.


Car Guy

Super Moderator
It's not possible with the current browsers. Once the page has been sent to the browser, their is no need for the server to do anything more. The server has NO way of knowing what anyone is doing with that page unless they click on a link or perform some similar action, just viewing it isn't enough.

It would take a change on the browser to send a notification that the page has been closed. Good luck convincing the them that is benefits anyone other than web site owners.
I guess I’m grasping at straws, but might there be some code that I could add to my webpages to accomplish this? For example, when one of my webpages is closed, a “window.onunload” event (or something similar) could be set to trigger an email to me.


Car Guy

Super Moderator
An email sent out every time a webpage is closed! That could mean several hundred emails a day for many people.

It has to be an interaction between the browser and the sever. When no action is taken by either no event can be recorded.

Once the server delivers the page to the browser, it is up to the browser to act if an action is to be recorded. The way the page is handled by the browser would need to change.
I only get one or two page hits per day, typically from different visitors, so there is no record of time spent. That is why I'm interested in how long a visitor stays on one of my pages or whether they leave immediately without reading anything. Anyway, thanks for taking the time to explain why what I want cannot be done.

Much appreciated Car Guy.


Car Guy

Super Moderator
If you split your page, and have a part 2, then you have a better chance at gauging your visitor's visit time, or least get an idea of how many visitors read the whole article.
Electrician Manly

The information in the StartCounter is very useful, so we browse through each post. If you provide still more extended data the time of the visitor staying on your site will be more.
Last edited by a moderator:
Create Coding like Google Analytics

Best thing to know the time spend by users in any website's page, you can put the code generated by Google analytic on you web pages. If you do not want to put it so just creates the coding for evaluating same with the help the Google Analytic. Its excellent!!
Using jQuery code for sending navigation information

I have a long landing page that I wanted to track the user navigation in it.
To accomplish this, I used the <noscript> code of the statcounter in custom.js:

/* =================================
=== STICKY NAV ====
================================= */

$(document).ready(function() {
scrollThreshold: 0.2, // Adjust if Navigation highlights too early or too late
filter: ':not(.external)',
changeHash: true
currentClass: 'current',
changeHash: true,
scrollSpeed: 1750,
scrollThreshold: 0.5,
filter: '',
easing: 'swing',
begin: false,
end: function() {
//I get fired when the animation is ending
var image = new Image();
image.src = "<proj_id>/0/<code>/1/?id=" + window.location.hash.substr(1);
scrollChange: function($currentListItem) {
var myHash = $currentListItem[0].firstChild.hash;
var heavyImage = new Image();
heavyImage.src = "<proj_id>/0/<code>/1/?id=" + myHash.substr(1);


Seems to work.
I know there is a code when the page is unloaded (as some landing page offer me "special offer" when I try to close the page. In this code another image load can be inserted to get exit indication.

BUT: I do want to get the 'anchor' indication in the statcounter logs. How can I get it?

Thank you,

Not open for further replies.