> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crispstats.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> CrispStats is a hosted, privacy-first analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing and no data import except a site's history from a Plausible export (Settings, Import and export). Websites use the script. iOS, Android, React Native and Flutter use the mobile SDKs in the install guides. Those SDKs are source files, not a published package, and they do not read an advertising id.
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> The script tag is the main install; the npm package @crispstats/tracker does the same from code, never alongside the tag. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# Track a mobile app with CrispStats

> Send iOS and Android screen views, custom events, identify and revenue to the same CrispStats site as your website. No advertising id.

CrispStats tracks an iOS or Android app with the same site, the same public key and the same dashboard as the website. A screen view is a pageview. Custom events, identify and revenue use the same names they use on the web.

There is no advertising identifier. The SDK creates a random install id once, keeps it on the device, and the collector hashes it with the site id before storing it. The IP address is used to place the event on the map and is then discarded. The raw User-Agent is never stored.

## Pick a guide

| App | Guide |
| - | - |
| Swift, UIKit or SwiftUI | [iOS](https://docs.crispstats.com/install/ios.md) |
| Kotlin | [Android](https://docs.crispstats.com/install/android.md) |
| React Native | [React Native](https://docs.crispstats.com/install/react-native.md) |
| Flutter | [Flutter](https://docs.crispstats.com/install/flutter.md) |

## Get the SDK

Each SDK is one source file that you download and add to the app. There is no package to install from npm, CocoaPods, Maven or pub.dev, and the file has no dependencies of its own.

| SDK | File |
| - | - |
| iOS | [`CrispStats.swift`](https://crispstats.com/sdk/ios/CrispStats.swift) |
| Android | [`CrispStats.kt`](https://crispstats.com/sdk/android/CrispStats.kt) |
| React Native | [`crispstats.ts`](https://crispstats.com/sdk/react-native/crispstats.ts) |
| Flutter | [`crispstats.dart`](https://crispstats.com/sdk/flutter/crispstats.dart) |

To update, download the file again and replace the old one. The SDK version is the `sdk_version` property on every event.

Use the same public key as the website, the `cs_pk_…` value from **Settings**, **Tracking code**. One site then shows the website and the app together.

## An app with no website

A site does not need a domain. When you add one, choose **Mobile app** and enter the app's bundle id (iOS) or application id (Android), such as `com.acme.app`, where a website enters its domain.

* The install step then shows the four SDKs, with your id already in the snippet.
* One app site takes both platforms. The iOS and Android apps send to the same public key.
* An application id may contain an underscore, such as `com.acme.my_notes`. It is stored in lower case.
* If the app gets a website later, add its domain under **Settings**, **General**, **Additional hostnames**. The script tag and its options then appear in **Tracking code**.

If the app already has a website on CrispStats, do not add a second site: use the website's public key in the app, as above.

## What you see in the dashboard

| In the app | In the dashboard |
| - | - |
| Screen name, such as `Pricing` or `Settings/Account` | A page, `/Pricing` or `/Settings/Account` |
| Bundle id or application id | The hostname |
| iPhone or Android phone | Device **mobile**, browser **iOS app** or **Android app**, OS **iOS** or **Android** |
| iPad or Android tablet | Device **tablet** |
| App version, build, OS version, SDK | Event properties `app_version`, `app_build`, `os_version`, `sdk`, `sdk_version` |

Filter the browser breakdown to **iOS app** or **Android app** when you want the app without the website. The website's hostname allowlist does not apply to the bundle id. An excluded path does: a pattern that matches the screen path drops that screen.

## Campaigns and referrers

An app has no address bar, so the SDK cannot see where a user came from. When a deep link or a push notification opens the app, pass its campaign tags with the screen it opens. Every SDK has a helper that reads them from the link, and each guide shows the call.

The tags are read the same way as on a web page: `utm_source` and `utm_medium` set the channel, and `utm_campaign`, `utm_term`, `utm_content`, `ref` and ad click ids such as `gclid` are kept. A referrer URL you pass is classified with them. Both apply to that one screen view and start a new session when the campaign differs from the last one.

## Visitors and sessions

The install id does not change when the phone moves from Wi-Fi to cellular, and it does not rotate at midnight. The collector stores a hash of it, a different hash on every site, so the id cannot be matched across sites.

A session still ends after 30 minutes away, or when a later screen arrives with a different campaign. When the app returns to the foreground after 30 minutes or more, the SDK counts the current screen again, so the new session starts with a screen view. The overview's visitor total still adds one for each day an install is seen, across the range you pick, unless [persistent visitors](https://docs.crispstats.com/privacy/persistent-visitors.md) is on for the site. Turning that on also stores an id in the browser on the website.

Events sent while the device is offline wait on the device, up to the newest 100, and are stored when they arrive. The SDK tries again when the app starts, when it returns to the foreground and after each new event. The dashboard uses the time the collector received them.

## What an event looks like

A screen view is a normal collect request, with an `m` block that only an app sends:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "k": "cs_pk_xxxxxxxx",
  "t": "pageview",
  "u": "app://com.acme.app/Pricing",
  "vid": "0123456789abcdef0123456789abcdef",
  "m": {
    "os": "ios",
    "id": "com.acme.app",
    "v": "1.4.0",
    "b": "42",
    "ov": "18.2",
    "d": "phone",
    "sdk": "ios",
    "sv": "1.1.0",
    "sn": "Pricing"
  }
}
```

`vid` is the install id, 32 hex characters. `sn` is the screen name. `os` is `ios` or `android`. `d` is `phone` or `tablet`. Campaign tags travel in the query string of `u`, such as `app://com.acme.app/Pricing?utm_source=newsletter`, and a referrer in `r`. Revenue uses `a` in minor units and `c` as a three-letter currency, the same as the website. A negative amount is ignored: refunds come from the payment provider.

The website script never sends `m`. An HTTP client that posts an ordinary pageview, with no app block, is still dropped as a bot.

## Privacy

The SDK does not read the Identifier for Advertisers, the Android advertising id, or the device serial. It does not fingerprint the device. Opt out with the SDK's `optOut` call: queued events are dropped and nothing further is sent until `optIn`.

Revenue from the App Store and Google Play can still arrive through [RevenueCat](https://docs.crispstats.com/revenue/revenuecat.md), [Superwall](https://docs.crispstats.com/revenue/superwall.md) or [App Store Connect](https://docs.crispstats.com/revenue/app-store.md). Those connections are separate from the SDK. Pass the same user id to `identify` and to the store if you want a purchase linked to the install.

> [!WARNING]
>
> Count each purchase once. If RevenueCat, Superwall or App Store Connect is connected to the site, do not also call the SDK's `revenue` for the same purchase: both would be stored and the total would double. Use `revenue` for sales that no connected provider reports.

## Next steps

> [card] [iOS](https://docs.crispstats.com/install/ios.md)
>
> Add the Swift file and count the first screen.

> [card] [Android](https://docs.crispstats.com/install/android.md)
>
> Add the Kotlin file. No extra library.

> [card] [React Native](https://docs.crispstats.com/install/react-native.md)
>
> Count screens from JavaScript.

> [card] [Flutter](https://docs.crispstats.com/install/flutter.md)
>
> Count screens from Dart.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.