I want to track all user actions in order to record the user behavior. For example, a user clicks on a link and I want to call a method that does something with that information before executing the page load. This should also work with mouse hover events, keyboard input or any other user interaction.
Asked
Active
Viewed 7,454 times
1 Answers
15
Wow, that's some big brother stuff you're asking for ;)
You could do something like this:
function bigBro(e) {
console.log(e);
}
$(document).bind("click keydown keyup mousemove", bigBro);
This can be used before load and DOM-ready, and you can get lots of info from the Event Object.
Regarding hover, you'll have to detect that yourself by checking the element the cursor is over by the target
property of the Event Object.
On a side note, this code will be very cpu intensive since the callback will be executed everytime you move the mouse, click or type.

mekwall
- 28,614
- 6
- 75
- 77
-
1Concering Big Brother: It's for an application where people know that every of their actions is recorded (like a macro recorder). Thanks for your idea, i'll dive into it for testing. – Alp Sep 21 '11 at 08:54
-
@Alp, yeah I kinda figured that out, hence the smiley - best of luck to you! :) – mekwall Sep 21 '11 at 09:03
-
Please also see the follow-up question: http://stackoverflow.com/questions/7511396/jquery-control-page-reloads-or-moving-away-from-the-current-page – Alp Sep 22 '11 at 07:55
-
1I would think that keyup/down or mousemove is not a user interaction for chrome, my experience in this is that the user has to click – René Baudisch Oct 25 '19 at 12:00