Sever-side vs Client-side data collection

Best practices on whether to collect data on server or client side.

Updated over a week ago

We frequently encounter a common inquiry: "Should I opt for one of our client-side libraries or one of our server-side libraries?" Below, you'll find some concise insights into why you might consider either option.


Not stored in your database

Data best suited for client-side tracking typically consists of information that you wouldn't typically store in your database. This includes metrics like page views, button clicks, page scroll length, mouse movements, social shares, and likes.

Ease of client-side tracking

Certain data, such as UTM tags, operating system details, device types, or cookie-based information like returning visitors, are most efficiently tracked on the client-side. Naturally, some data, like mouse movements, is exclusively available on the client-side and should be tracked there.

Events required for client-side-only destinations

Some destinations can only receive data when the event originates from the browser. These destinations rely on cookies, and most lack an API that Segment can use to send server-side data. You can find more details in our Analytics.js documentation.


Payment events

Payment transactions often occur when customers are offline, and precision in tracking these events is paramount. Server-side tracking tends to be more accurate than user devices due to its controlled environment.


In general, client-side data suffices for observing overall trends but may not achieve absolute perfection. This is especially relevant if your customers frequently employ tools like ad blockers or use outdated or non-standard browsers. For example, if you're triggering emails based on specific events, it's advisable to ensure that user profiles are sent through our servers to avoid overlooking anyone or sending incorrect emails.

Calculated from your database

Data that requires calculations based on database queries, such as "Friend Count" for social networks, is well-suited for server-side tracking. Of course, since provides computed properties, you often are better off relying on making calculations, keeping your code clean of scores and other metrics.

Sensitive information

To maintain the security of sensitive data and prevent user exposure, it's best to transmit such information via server-side methods, keeping it beyond the reach of browsers.

Did this answer your question?