Client vs. Server Events: Are You Tracking Data the Wrong Way?
Quick Overview
Generally, user interaction events like button clicks or menu navigation should be tracked client-side, while crucial business logic events such as successful logins, revenue, transactions, or sign-ups should always be tracked server-side to ensure 100% accuracy and avoid data loss from client-side blockers or delays.
Key Points: User interaction events (e.g., button clicks, menu navigation) are generally recommended to be tracked client-side. Critical business events like successful logins, revenue, transactions, or sign-ups must be tracked server-side for 100% accuracy. Server-side events are more accurate in terms of storage compared to client-side events because client-side tracking can be blocked by cookie blockers or ad blockers, or suffer from delays. If an event is recorded client-side, the timestamp reflects the moment of interaction, but if the server sends the event later (e.g., 10-15 second delay), the server-side timestamp will be generated later, not at the exact time of interaction. When tracking KPIs like revenue or sign-ups, always use server-side tracking to guarantee accuracy. When using client-side information (like session IDs or platform details for iOS/Android) in server-side events, fetch that client data first, add it as properties to your server event, and then send the server event.
Context: This discussion addresses the best practices for implementing event tracking in product analytics platforms like Amplitude, focusing on the decision criteria for sending events from either the client-side (user's browser/app) or the server-side (backend infrastructure). The context revolves around ensuring data integrity, accuracy, and reliability for key performance indicators (KPIs) and user behavior analysis.
Detailed Analysis
The core recommendation is to use client-side tracking for user engagement events (like button clicks, menu navigation) where the exact moment of interaction is most important, even if there is a slight delay in reporting. Conversely, critical business metrics (KPIs) such as revenue, number of transactions, or sign-ups must be tracked server-side. Server-side tracking is preferred for these because it is more accurate regarding storage and is not susceptible to client-side issues like cookie blockers, ad blockers, or browser limitations that can drop events. For instance, a successful login should be tracked via the server, even if the initial click on the login button is tracked client-side. A critical point is that if client-side data (like session IDs or platform—iOS/Android) is needed for analysis, it should be fetched on the client, added as properties to the server-side event, and then the server event should be triggered. This ensures that crucial data points are recorded accurately and consistently, regardless of client environment variables.