User Activity Tracking or Logging with javascript

895    1 year ago

Is it possible to track every action of a user on a webpage and creating log of it? The idea is to transfer log of user actions to server via AJAX and saving it. On each event for each element I can write code/logic to write some log in console, but I was wondering if there is any library/shortcut available which can log all actions on webpage at client side including events and actions such as copy, paste, click, double click, selection etc. with their element reference.

Answers { 1 }
1 year ago

You can use ready-made solutions:

You can do amazing stuff with Google Analytics and its Event Tracker:

If you're looking for a custom-made solution, you can try the following one with PHP and JavaScript:

Keep in mind that using third-party solutions is better performance-wise. Writing the coordinates of the mouse movements in a database in real time, needs a lot of resources.