# Analytics

See active users, screens, sessions, retention and push opens for each app.

## What you get

Everything shows on your app's **Analytics** page in the dashboard. App opens count automatically. The rest is opt-in and reported by the `native-notify` SDK.

| Metric                                                                                                       | Needs                                                                      |
| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| **Active users**: DAU, WAU and MAU with growth, new vs. returning users, stickiness (DAU ÷ MAU), daily trend | Nothing                                                                    |
| **Screen usage**: most-viewed screens, ranked, with daily trends                                             | `analytics: { screens: true }` and `trackScreen()` or the Expo Router hook |
| **Sessions**: per day, average length                                                                        | `analytics: { sessions: true }`                                            |
| **Push opens**: delivered vs. opened and unique opens per notification, open-rate trend, best send times     | `analytics: { opens: true }` (SDK v5.1+)                                   |
| **Retention**: weekly cohorts of first-time users who come back                                              | Nothing                                                                    |
| **Send failures**: delivery failures by error code                                                           | Nothing, collected on the server                                           |

## 1. Update the SDK to v5.1 or later

```bash
npm install native-notify@latest
```

## 2. Enable what you want

```js
import { NativeNotify } from "native-notify";

NativeNotify.init({
  appId: yourAppId,
  appToken: "yourAppToken",
  analytics: {
    screens: true,   // screen views
    sessions: true,  // foreground session length
    opens: true,     // per-notification open rates
    deviceId: true,  // stable device id for unique screen views and opens
  },
});
```

Every flag is independent and defaults to `false`. Sessions and push opens need nothing beyond their flags. See [Analytics setup](/docs/analytics/setup).

## 3. Track screens

Only with `screens`. Expo Router needs one line in the root layout. Other navigators call `trackScreen()` — see [Screen tracking](/docs/analytics/screens).

```jsx
import { Slot } from "expo-router";
import { useNativeNotifyScreenTracking } from "native-notify";

export default function RootLayout() {
  useNativeNotifyScreenTracking();
  return <Slot />;
}
```

## How it's counted

An app open is recorded when your app registers, at most once per device or subscriber every 30 minutes. Active users follow the [monthly active users](/docs/billing#how-monthly-active-users-are-counted) rule: devices count, and a subscriber counts only when none of its own devices does.

## Agents

Agents read the same data through the analytics tools on the [MCP server](/docs/mcp-server).
