Docs
SDK

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.

View as Markdown

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.

Track these standard events wherever they happen in your app. Consistent names let Layers map them to activation and revenue automatically.

EventFires whenKey properties
app_openThe app launches
sign_upA user creates an account
loginA user logs in
purchase_successA purchase completesproduct_id, revenue, currency, transaction_id
subscription_startA subscription beginsproduct_id, revenue, currency
trial_startA free trial startsproduct_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:

  • revenue and currency — 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

On this page