when the visitor goes to a webpage, how do we know the visitor is actually showing the page on top (instead of going to another tab or app already).
also how do we know how long the user has read the page or how long the page stayed open?
when the visitor goes to a webpage, how do we know the visitor is actually showing the page on top (instead of going to another tab or app already).
also how do we know how long the user has read the page or how long the page stayed open?
On page load, save the current time in JavaScript, and on page unload (when the user closes his/her window) send an Ajax request to your server with the time minus the time that you recorded to get the duration. That would probably be your best bet. As for finding out if the window is on top, I don't think there is any reliable way of doing that.
Google analytics is the best free analytics AFAIK. It shows you all you need.
Install a camera and time the video. :)
<rant>
Frankly, why do you need to know? How long it takes me to understand what you write? How long I went to lunch? Is total surveillance of your visitors a Good Thing(tm)?
I already gave you my IP address and the fact that I did visit your page. Is the size and color of my underwear really that important?
As a web surfer, I hate web bugs, data collecting JavaScript and any kind of surveillance in general. If I don't want to give something to you, then don't try to steal it from me.
People all around the globe begin to understand how precious and endangered their privacy is. Criminals come up with more cunning and more devious ideas to abuse data that someone collected. Websites start to fall apart when I visit them without JavaScript. NoScript tells me "jdhsdg.com" wants to run some stuff in my browser. What should I do? Allow? Deny? What happened to good old honesty? What do the marketing guys have to hide that they use names like that?</rant>
[EDIT]
If you need to know whether your site is bad, call in people from the street and watch them (hence "Install a camera"). This way, you can ask them what they think, instead of guessing by watching what their mouse pointer does. Maybe their pet is playing with it?
Don't do this in the wild with unsuspecting victims. That will only make them mad when they find out and in the Internet, your reputation is the only thing with value.
[EDIT2] To improve a web site, use a usability lab. Guesswork with second-level artificial data, which has no fixed relation to what you want to measure, will deceive you. You can't tell what people on earth do by watching the lights during the night from the moon.
At least not unless you pull in lots of data. Google is able to tell what people are interested in by collecting huge amounts of data and search it for patterns. They do attach tokens to browsers to track what an individual does but for the analysis, they join the patterns of millions of individuals.
Also always remember that this data might be valuable to a criminal. The more valuable your data, the more energy they will invest in finding a way to make money from it. They could crack your famous site to distribute viruses, they could crack your server to encrypt your data and blackmail you for ransom, they could copy the data and sell it to a competitor, or they might use it for one of their own schemes.
The various criminal organizations around the globe make billions every year with Internet related crime.
From my point of you, you should really ask yourself: How much is this data worth? How accurate can it ever be? How much will it tell me and how risky is it to collect? How easy is it to fool my scheme? For example, I could create a script which hammers your service, telling it that I'm actively reading some of your pages for hours. Or I could disable JavaScript for your site, see that it doesn't work, and simply walk away, never coming back.
So far, you only asked what's in for you. Start thinking what's in for your customers and about the worst case scenarios.
i was thinking whether some websites use onmousemove or onscroll to call a function, and then every 1 minute, report the user activities back to the server using AJAX.
That's a good point Aaron. You can't avoid the web from becoming like the real world...intrusive (commercial phone calls and others statistic stuff)
Jian, you may be able to know such a thing by calling a timer each 4 or 5 seconds which calls a dynamic page with post or get fields that contain the guest IP, the page name, and the timestamp of the page onload event, and compare it to right now.
You also should have a look at push methods like comet
ajaxian.com/wp-content/images/comet.png
I use woopra for some time now at it is just great! Still beta and still free but works like a dream. Great managment tool!
Open Source Google Analytics alternative: Piwik. Written in PHP, JS; runs on MySQL.
From their site:
Piwik is a downloadable, open source (GPL licensed)
web analytics software program.
It provides you with detailed reports on your website visitors:
the search engines and keywords they used,
the language they speak, your popular pages ...