Tracking events
The events worth tracking with the Layers SDK, the properties to send with them, how to identify users, and how the SDK batches and flushes events.
Once the SDK is initialized, you track an event by name with an optional bag of properties. The SDK auto-tracks sessions and app-lifecycle events; everything below is what you add on top so Layers can measure activation, revenue, and retention.
Recommended events
Track these standard events wherever they happen in your app. Consistent names let Layers map them to activation and revenue automatically.
| Event | Fires when | Key properties |
|---|---|---|
app_open | The app launches | — |
sign_up | A user creates an account | — |
login | A user logs in | — |
purchase_success | A purchase completes | product_id, revenue, currency, transaction_id |
subscription_start | A subscription begins | product_id, revenue, currency |
trial_start | A free trial starts | product_id |
Add any custom events that matter to your product — pass the event name and a properties object the same way.
layers.track('purchase_success', {
product_id: 'premium',
revenue: 9.99,
currency: 'USD',
transaction_id: 'txn_abc123',
});Event properties
Always send the properties that give an event meaning:
revenueandcurrency— on every purchase or subscription event, so Layers can attribute revenue to campaigns.product_id— on any product-related event.transaction_id— on purchases, for verification and de-duplication.
Identify users
After a user authenticates, associate the session with your user ID so events and attribution stitch to the right person. Set the user ID (via identify / setUserId, per your platform's SDK) and any properties you want to segment on — subscription tier, signup date, and so on.
Identify the user after authentication, once you know who they are — the SDK auto-tracks sessions and lifecycle events before then regardless.
Batching and flushing
The SDK queues events and sends them in batches — it flushes every 30 seconds or every 20 events, whichever comes first. You don't manage the queue; just call track() and the SDK handles delivery, retries, and ordering.
Debug logging
Enable debug logging during development to see events as they're queued and sent. In the Expo and React Native SDKs, pass enableDebug: __DEV__ when you construct the client (see Installation). Turn it off in production builds.
See also
- Installation — per-platform setup.
- Attribution — how the SDK attributes installs.
- SDK health & verification — confirm the events you expect are arriving.
Prompt your coding agent
A ready-to-paste prompt that instructs Claude, Cursor, or any coding agent to install and instrument the Layers SDK in your app — install, initialize, and track the events that matter.
Attribution
How the Layers SDK attributes installs to campaigns, plus the platform-specific settings — iOS clipboard attribution and App Tracking Transparency, and Android Install Referrer.