Skip to main content
The SDK is one Kotlin file, CrispStats.kt. It uses only the Android SDK and the Java standard library, so there is no extra dependency. It works from Android 5.0 (API 21). It keeps a random install id on the device, queues events while the network is down, and sends them to https://in.crispstats.com/e. It does not read the advertising id.

Add the file

From the app module, download the file into the package com.crispstats.sdk:
The app needs the internet permission. Most apps have it already. If yours does not, add it to AndroidManifest.xml:

Create the client

Create one client in your Application class and keep it for the life of the app.
Register the class in AndroidManifest.xml with android:name=".AcmeApp" on the <application> element. Replace cs_pk_xxxxxxxx with the site’s public key from Settings, Tracking code, and com.acme.app with the application id. appVersion is the version name. appBuild is the version code and can be left out. osVersion defaults to Build.VERSION.RELEASE, so you can leave it out too. If the key does not start with cs_pk_, the application id has characters other than letters, digits, ., _ and -, or the version is empty, the client sends nothing and says why once in Logcat in a debug build. It never throws.

Count screens

Call screen when the visible destination changes:
A screen name is one to eight segments separated by /. Each segment starts with a letter or a digit and then uses letters, digits, spaces, ., _ and -, up to 80 characters. The whole name is at most 200 characters. Settings/Account is stored as the page /Settings/Account. A name that breaks these rules sends nothing. screen sends the time spent on the previous screen before it counts the new one. While at least one activity is started, the current screen’s timer runs. When the last activity stops, the timer pauses and the time so far is sent. When the app comes back within 30 minutes, the same screen keeps adding up. After 30 minutes or more in the background, the screen is counted again, because a new session has started.

Events, users and revenue

revenue takes minor units: 4900 with USD is $49.00. A negative amount is ignored. Pass the campaign tags of the link that opened the app to the first screen call. CrispStats.campaignFrom reads them from the link:
A link such as acme://pricing?utm_source=newsletter&utm_medium=email sets the channel to email. You can also pass the pairs yourself, and a referrer URL:
Keys are lower-cased and keep letters, digits and _, up to 32 characters. Values are trimmed and kept when they are 1 to 200 characters. At most 10 pairs are sent. The referrer is sent when it is 1 to 2,000 characters. Both apply to that one screen view only.

Tablets

The device is detected from the smallest screen width: 600 dp or more counts as a tablet. To set it yourself, pass device in onCreate:

Opt out

optOut drops anything still queued and sends nothing until optIn. The choice is kept across launches.

Errors

The message is grouped on the Errors page.

Offline and retries

Each event is one request. Events wait in a queue of up to 100, kept in SharedPreferences, and the oldest is dropped when it is full. The SDK sends the queue when the client is created, when the app returns to the foreground and after each new event. After a failure it tries again after 1 second, then 2, 4 and so on, up to once a minute. A request that takes longer than 10 seconds counts as a failure. Storage and network run on one background thread, so no call blocks the main thread.

What gets stored

The screen is a pageview. The browser breakdown shows Android app, the OS shows Android, and the device shows mobile or tablet. The app version, build, OS version and SDK name are properties on the event. The language and time zone come from the device settings. The install id itself is not stored. See mobile apps for Play Store revenue through RevenueCat.
Last modified on December 2, 2026