gitmyhub

user-tracking-demos

JavaScript ★ 91 updated 7y ago

demos of tracking users with JavaScript

This repository demonstrates different ways to track what users do on a website by sending that information back to a server. It's useful if you're building analytics, monitoring user behavior, or understanding how websites collect data about their visitors.

The repo contains five different methods for accomplishing this tracking, each with tradeoffs. Some methods send data immediately when a user performs an action, while others wait or batch multiple events together. Some work even if the user closes the page mid-request. The goal is to show developers the pros and cons of each approach—for example, one method might be faster but less reliable, while another guarantees delivery but might slow down the page.

To use it, you clone the repository, install its dependencies, and run a local server on your computer. Then you visit the demo pages in your browser, interact with them (clicking buttons or navigating away), and watch the server logs in your terminal to see which tracking methods actually captured your actions. It's hands-on learning: you immediately see what worked and what didn't.

This would be valuable for anyone building a website or app who wants to understand the mechanics of user tracking—especially if you're trying to decide which method to use in your own project. It's also helpful for learning how the browser communicates with servers in different scenarios, like when a page is unloading or the connection is slow. The author included a blog article (in Chinese) with more detailed explanations of the technical concepts behind each method.