# Analytics

See active users and growth, screen usage, retention, session activity, and push open rates for your app — built into Native Notify.

Native Notify includes analytics alongside your push notifications: active users with growth rates, which screens people use, retention, session activity, and how many of your notifications get opened. Everything shows up on your app's **Analytics** page in the dashboard as the data arrives.

All analytics reporting is **opt-in and SDK-driven** — you enable the features you want with a small config and the `native-notify` package reports the data for you. Nothing is tracked by default.

## What you get

| Metric        | What it shows                                                                                                               | Needs                                                                   |
| ------------- | --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| Active users  | DAU / WAU / MAU with deltas vs. the previous period, new vs. returning users, stickiness (DAU÷MAU), and a daily trend chart | Nothing extra — app opens are counted when the SDK registers            |
| Screen usage  | Your most-viewed screens, ranked, with per-day trends                                                                       | `analytics: { screens: true }` + `trackScreen()` / the expo-router hook |
| Sessions      | Sessions per day and average session length                                                                                 | `analytics: { sessions: true }`                                         |
| Push opens    | Per-notification delivered vs. opened, unique opens, open-rate trend, best send times                                       | `analytics: { opens: true }` (SDK v5.1+)                                |
| Retention     | Weekly cohorts — how many first-time users come back in later weeks                                                         | App-open data only (automatic)                                          |
| Send failures | Why deliveries failed, grouped by Expo error code                                                                           | Nothing extra — receipt errors are collected server-side                |

## Quick setup

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

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

2. **Enable the features 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 accurate unique-user counts
     },
   });
   ```

   Every flag is independent and defaults to `false`. See [Setup](/docs/analytics/setup) for the details, including the privacy notes.

3. **Track screens (only if you enabled \`screens\`)**

   Expo Router apps need one line in the root layout; every other navigation library calls `trackScreen()` where you already listen for route changes:

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

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

   See [Screen Tracking](/docs/analytics/screens) for the full walkthrough (including React Navigation).

That's all — the SDK reports the data and the dashboard renders it. Session tracking and push-open reporting need no extra code beyond the flags above.

## Where the numbers come from

- **Active users / views** are recorded automatically every time your app registers with Native Notify (the `registerNNPushToken` call on app start). This is why they work with zero setup.
- **Screen views** are reported by the SDK — batched for about two seconds and deduplicated (the same screen twice in a row counts once).
- **Push opens** are reported when a user taps a notification. Native Notify includes a hidden `nn_notification_id` in every push payload; the SDK echoes it back on tap. Taps on old notifications (sent before the tracking ship) and group sends are not attributable and are skipped.
- **Retention and best send times** are computed from the app-open and open-tap history described above.

## Agents can pull this too

Every number on these pages is available to AI agents through the Native Notify MCP server — `get_analytics_summary`, `get_active_users`, `get_views`, `get_screen_usage`, `get_retention`, `get_best_send_times`, `get_notification_delivery_stats`, `get_notification_failures`, and `export_analytics_csv` (CSV export). Connect once and ask: *"How is my app growing this month, and which screens should I improve?"* — see [MCP Server](/docs/mcp-server).
