# Tracking events (/docs/sdk/tracking-events)



Once the SDK is [initialized](/docs/sdk/installation), 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 [#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.

```ts
layers.track('purchase_success', {
  product_id: 'premium',
  revenue: 9.99,
  currency: 'USD',
  transaction_id: 'txn_abc123',
});
```

## Event properties [#event-properties]

Always send the properties that give an event meaning:

* **`revenue`*&#x2A; and &#x2A;*`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 [#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.

<Callout type="info">
  Identify the user **after** authentication, once you know who they are — the
  SDK auto-tracks sessions and lifecycle events before then regardless.
</Callout>

## Batching and flushing [#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 [#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](/docs/sdk/installation)). Turn it off in production builds.

## See also [#see-also]

* [Installation](/docs/sdk/installation) — per-platform setup.
* [Attribution](/docs/sdk/attribution) — how the SDK attributes installs.
* [SDK health & verification](/docs/api/concepts/sdk-health) — confirm the events you expect are arriving.
