views:

318

answers:

8

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?

+1  A: 

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.

musicfreak
when the user closes the window, is the AJAX still runnable though?
動靜能量
Yeah, with the "unload" event. I don't remember if it works on all browsers, but it should.
musicfreak
But we have very less time for this ;-)
Shoban
+11  A: 

Google analytics is the best free analytics AFAIK. It shows you all you need.

Shoban
Wow, I feel stupid, didn't even think of that.
musicfreak
+5  A: 
Cherian
Holy ****. Time to write a Greasemonkey script to filter out any website which uses this.
Aaron Digulla
@Aaron, upvoted even though the tech seems very cool, but for debugging purposes on knowing and willing subjects only.
Kris
Why does it matter if a website tracks what parts of the page you interact with most?
Ian
+7  A: 

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.

Aaron Digulla
it can help too... such as improving pages that users quickly exit.
動靜能量
Excellent point. +1
JesperE
If you can't measure a system you can't improve it. Analytics is a must on any non trivial system, web or otherwise.
ilivewithian
@Jian Lin: if you need to know whether your site is bad, call in people from the street and watch them (hence "Install a camera"). Don't do this in the wild with unsuspecting victims. That will only make them mad when they find out.
Aaron Digulla
@ilivewithian: AFAIK, I can disable Analytics without adverse effects, so I can live with that. Incidentally, Analytics is disabled in my firewall and all my web browsers. My data is mine. You want it, you pay for it.
Aaron Digulla
@Aaron so if a company looks at the web log and see that people like to visit webpages of a certain topic, and add more content about that topic, that invades your privacy too? How about if a company found that more and more people use Firefox and decide to make better support for Firefox? Do you feel it invades your privacy too?
動靜能量
@Jian Lin: When I visit a site, I know what I'm giving them: My (obfuscated) browser id and my IP address (or rather the one of my proxy). That's what they got and there is little I can do to prevent them to abuse this information in ways I can't think of. Everything else goes into the "gray" zone. The more you collect, the more people will hate you, no matter your intentions (see Google). So be careful. You can ruin your reputation only once. :)
Aaron Digulla
Rule of thumb: Data that isn't collected can't be abused. Data that is collected will eventually be abused. As always, reality beats paper.
Aaron Digulla
@Jian Lin: One more thing: If you sell to people from Germany, some courts consider the IP address private data of the customer and rule it to be illegal to peek at it (they judged this the same as secretly opening letters in a post office). Counting visits is OK, but not identifying individuals. Others courts have ruled differently, though.
Aaron Digulla
Outside of the "wanting to know what needs improvement on the site" issue... It costs time and money to create and support a web site. Ads are a common way to generate that money. Being able to provide potential ad clients with numbers (unique users, return visits, time spend on pages) means you can better market your pages.
RHSeeger
A: 

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.

動靜能量
A: 

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

William Huart
When this starts to get around, Adblock will start to distribute Greasemonkey scripts...
Aaron Digulla
+2  A: 

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!

http://www.woopra.com/

Holli
+2  A: 

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 ...
The MYYN