# 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 three
dashboard views: **Overview**, **Links**, and **Events**.

:::note[Links and Events need a paid plan]
**Overview** is available on every plan. **Links** and **Events** 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

All three views share the same filters, that is selected app, platform, and date range, so numbers stay comparable when you move between them.

Analytics can also be delivered to your own endpoint on a schedule. See [Webhooks](https://detour.swmansion.com/docs/platform/fundamentals/webhooks).

### Overview

Overview summarizes performance on one page. It shows four things:

- link trend
- organic vs non-organic install attribution
- top event distribution
- retention comparison

For cohort and N-day methodology, see [Retention](#retention).

### Links

Link-level diagnostics: day-by-day link stats, plus a breakdown by path and query parameter. Use it to compare campaign routes and see where clicks and matches come from.

[Smart banner](https://detour.swmansion.com/docs/platform/advanced/smart-banners) taps are recorded like any other click. They carry `utm_source=smart_banner`, a `utm_campaign` of your choosing, and a `dtb` parameter identifying the banner, so all three appear in the parameter breakdown.

The same figures are available over HTTP, with pagination and filtering, through [Export Analytics](https://detour.swmansion.com/docs/platform/advanced/api-management#export-analytics).

For the redirect and matching behavior behind these metrics, see [Click Handling & Redirect Flow](https://detour.swmansion.com/docs/platform/architecture/click-handling).

### Events

SDK event activity in the selected window:

- total event count
- timeline trends per event name
- drill-down tables for event totals and individual occurrences

## Organic vs non-organic

Every install is labeled by where it came from, which is what makes campaign
effectiveness measurable:

- **Non-organic** — the install was attributed to a specific click on a Detour link.
- **Organic** — no prior link interaction was detected.

## Manual event tracking

Automatic tracking covers the link funnel. To track later actions, for example
sign-ups or purchases, log events yourself through the SDK's analytics API.

If you are still setting up the integration, start with [Getting Started with Detour](https://detour.swmansion.com/docs/platform/fundamentals/getting-started).

```typescript
import { DetourAnalytics, DetourEventNames } from "@swmansion/react-native-detour";

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/)