# Analytics

Installing the SDK is enough to start collecting link data. Clicks, installs,
and attribution are tracked without any extra calls. You read the results in the
Dashboard views **Overview**, **Links**, **Events**, and **Smart banners**, and
you can add history from another attribution provider in **Imports**.

:::note[Links, Events, and Smart banners need a paid plan]
**Overview** and **Imports** are available on every plan. **Links**,
**Events**, and **Smart banners** are available on Starter and above. See
[Billing & Payments](https://detour.swmansion.com/docs/platform/fundamentals/billing).
:::

## Automatic tracking

The click and install flow produces these metrics on its own:

- **Clicks** — counted from recorded click beacons.
- **Installs via link** — installs attributed to a matched click.
- **Fallbacks** — clicks that ended on non-mobile fallback flow.
- **Organic vs Non-Organic installs** — based on whether install was matched to a click.

## Dashboard views

**Overview**, **Links**, and **Events** share the same filters, that is selected
app, platform, and date range, so numbers stay comparable when you move between
them. **Smart banners** shares the app and the date range. **Imports** lists
DetourAnalytics.logEvent(DetourEventNames.Login);
DetourAnalytics.logEvent(DetourEventNames.Purchase, { value: 9.99, currency: "USD" });
DetourAnalytics.logRetention("day_7_return");
```

  ```swift
import Detour

DetourAnalytics.logEvent(.addToCart, data: ["sku": "abc"])
DetourAnalytics.logEvent("purchase", data: ["value": 9.99, "currency": "USD"])
DetourAnalytics.logRetention("day_7_return")
```

  ```kotlin
import com.swmansion.detour.analytics.DetourAnalytics
import com.swmansion.detour.analytics.DetourEventNames

DetourAnalytics.logEvent(DetourEventNames.Login)
DetourAnalytics.logEvent(DetourEventNames.Purchase, mapOf("value" to 9.99))
DetourAnalytics.logRetention("day_7_return")
```

  ```dart
import 'package:detour_flutter_plugin/detour_flutter_plugin.dart';

final detour = DetourService();
await detour.start(
  const DetourConfig(
    apiKey: "<REPLACE_WITH_YOUR_API_KEY>",
    appID: "<REPLACE_WITH_APP_ID_FROM_PLATFORM>",
  ),
);

await detour.logEvent(DetourEventName.login);
await detour.logEvent(DetourEventName.purchase, data: {"value": 9.99});
await detour.logRetention("day_7_return");
```

  ## Retention

Detour retention is **event-based**. It is calculated from SDK calls to `logRetention("<event_name>")`, grouped by retention event name.

### Data model

- Retention events are stored in analytics as a dedicated retention stream.
- They are tied to event name, device, time, and platform.
- Retention data is not mixed into regular event charts like Top Events and Events timeline.

### Cohorts and N-day logic

- A cohort is the group of devices that triggered a given retention event for the first time in the selected date range.
- `Day 0` is the first occurrence day, and later points (`Day 1`, `Day 2`, ...) show return behavior on following days.
- Retention is tracked up to **30 days** (`Day 0` to `Day 30`).
- Future dates are excluded to avoid artificial 0% drops on incomplete days.
- Platform filtering works the same way as in other analytics views.

### Metrics

Retention reporting shows:

- how many cohort devices returned on a given day,
- how large the original cohort was,
- and the resulting retention percentage.

When multiple cohorts are combined on one chart line, Detour uses weighted aggregation so larger cohorts have proportionally higher impact.

## Related pages

[Dashboard Walkthrough](https://detour.swmansion.com/docs/platform/fundamentals/Dashboard/)
  [Webhooks](https://detour.swmansion.com/docs/platform/fundamentals/webhooks/)
  [Getting Started with Detour](https://detour.swmansion.com/docs/platform/fundamentals/getting-started/)
  [Click Handling & Redirect Flow](https://detour.swmansion.com/docs/platform/architecture/click-handling/)
  [Universal Links & App Links](https://detour.swmansion.com/docs/platform/fundamentals/universal-app-links/)