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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With