Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery detect all dom event calls and user interactions

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.

like image 772
Alp Avatar asked Sep 21 '11 07:09

Alp


1 Answers

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.

like image 155
mekwall Avatar answered Oct 26 '22 23:10

mekwall