How to determine Time On Site in Javascript?
Google Analytics tracks 'Time On Site'. How would you do that effectively? Does it actually track when the user closes the browser or navigates away? Thoughts? I can't be 100% certain of course, but I would guess they use javascript and the onload and onunload events and/or setTimer to communicate with a web service via AJAX. This way they could figure out when users go to or leave a page on your site. Once the browser stops "pinging" the web service, it's assumed that they left your site. I'm sure there's some margin of error involved no matter how you do it, but you could get a pretty decent