Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
How to track mouse movement without crashing server

I've been tasked with developing metrics for how users interact with our web portal. A coworker suggested that I look into "heat maps" to monitor user mouse position. This idea seemed cool to me. It seems there are already some SaaS solutions, but our budget is thin, so I whipped up some javascript:

class UserLog {
  constructor(){
    // ...
    this.results = {... mouseMovements=[]}
  }
  /* ... more functions ... */

  trackMouseMovement(){
    document.addEventListener('mousemove', (event) => {
      this.results.mouseMovements.push({
        timestamp: Date.now(),
        x: event.pageX,
        y: event.pageY
      });
    });
  }
}

I am currently using a timer to send this array to my server every 10 seconds:

window.setInterval(() => {
  $.ajax({
    url: endpoint, 
    type: "POST",
    data: this.results,
  });
},10*1000);

I'm running into the mouseMovements array can get up to several hundred elements in length and makes my browser cry when the ajax executes.

I can try sending data more frequently, or I can try preprocessing the mouseMovements array:

preprocessData: results =>{
    const newResults= {
      ...results,
      mouseMovements: results.mouseMovements.filter((val, index) => index % 10 == 0)
    }
    return newResults
  }

(1) How do people implement a mouse tracking protocol that allows the user's machine to operate as usual and provides enough resolution on the back end to playback the user's session and understand how to improve their experience on the site?

(2) How often should I be sending the ajax requests to my server? I am looking at some major sites and noticing that their requests seem to be click-driven. Is tracking mouse movements and scrolls not optimal? Or is there a better way of collecting this information?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First, you need to throttle your API request, most of the collaborating products like the Figma design tool, in which you can see other people's mouse position in real-time, most likely sends mouse position once in 600ms.

600ms is janky, but if you think of mouse positions as keyframes, then you can animate between two mouse positions, so the user will always see smooth mouse movement, of course it depends on your animation algorithm.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!