Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda