I use such code to catch users clicks:
Event.observe(document, 'click',function(e){
var x = Event.pointerX(e);
var y = Event.pointerY(e);
//exec data storage over ajax
}
The problem is when the user click some link, the next function don't have time to execute entirely and I can't save the click data before redirect to the clicked link.
I saw some jquery implementation, but I don't use jquery.