Forum Moderators: open
It's one of the normal long-form salesletters. What I'm wanting to do is find the average time a visitor spends on the page.
Since it's a simple one page salesletter, log files won't work.
I would imagine this is possible with some javascript, but I'm clueless when it comes to javascript so I don't know if this would be something relatively simple or complex.
I've hunted around and can't find anything along these lines.
Any help pointing me in the right direction would be much appreciated.
<script type="text/javascript" src="/js/prototype.js"></script>
<script type="text/javascript">
var uniqueId = '<?php echo session_id();?>'; // or generate one with javascript/asp/whatever
function log(){
var url = '/log.php?id=' + uniqueId + '&st='+document.body.scrollTop;
new Ajax.Request(url, { method: 'get' });
setTimeout('log()', 1000); // 1000 = 1 second, increase to reduce server load
}
Event.observe(window, 'load', function() {log(); });
</script>
Of course, you might not want to include such a hefty library for a single purpose, but I'm sure you could find more uses for it. :)
Not that hard but you do need AJAX.
(used in a chat app, once I determine that user has left, user name removed from user list and message displayed to say user has left)