Send events and revenue from your server to DATALYR and see which channel, campaign and ad drove every conversion.
- Server-side truth. Signups, purchases and webhooks are recorded where they happen, so ad blockers cannot hide them.
- One customer, every touch. Server events join the same person your website and app track.
- No double counting. Pass a webhook's own event ID and redeliveries count once.
- Safe in production. The SDK never throws on a bad event, retries failed sends and drains its queue on shutdown.
The SDK needs Node 18 or later.
npm install @datalyr/apiFind your server API key in DATALYR under Settings → API. The key starts with dk_.
import { Datalyr } from '@datalyr/api';
const datalyr = new Datalyr({ apiKey: process.env.DATALYR_API_KEY });
// Track an action
await datalyr.track({
event: 'signup_completed',
userId: 'user_123',
properties: { plan: 'pro' },
});
// Attach traits to your user
await datalyr.identify('user_123', { email: 'user@example.com' });
// Record a conversion with its value
await datalyr.trackPurchase('user_123', { value: 49.0, currency: 'USD' });
// Before the process exits, send all queued events
await datalyr.close();Keep the API key on your server. Do not put it in browser or app code.
- Run the quick start with your API key.
- In DATALYR, open Events.
- Confirm that a
signup_completedevent arrives within 30 seconds.
If no event arrives, add debug: true to the constructor. Then read the process logs.
Your AI agent can install the SDK for you. Connect the agent to the DATALYR MCP server at https://mcp.datalyr.com/mcp. Then ask it to install server-side tracking. See DATALYR MCP.
- Node SDK reference: every method, option and event
- Examples: Express, Stripe webhooks and a basic script
- Changelog
- Other SDKs: Web · React Native · iOS (Swift)
- Bugs and feature requests: open an issue
- Security reports: see SECURITY.md
- Other questions: datalyr.com
MIT. See LICENSE.