When to use server-side vs client-side
Choose the right tracking layer for each type of event.
A common pattern is to track UI interactions client-side and confirm revenue or subscription events server-side, so critical business data is always captured accurately.
Node.js SDK
Install the server-side SDK in your Node.js project.saytics.track to record events from your backend.
HTTP API
If you’re working in a language other than Node.js, or you want to send events directly from a webhook handler, use the HTTP API. Send aPOST request to /v1/events with your event payload.
timestamp field is optional. If omitted, Saytics uses the time the request is received. Include it when replaying historical events or processing delayed webhooks.
Batching events
The Node.js SDK automatically queues events and flushes them to Saytics in batches, which reduces network overhead in long-running server processes. In serverless environments (such as AWS Lambda or Vercel Edge Functions), the process may exit before the queue has a chance to flush automatically. Callsaytics.flush() explicitly at the end of your handler to ensure all events are sent.