Documentation

Android SDK.

Installs, opens, screens, taps, links, notifications, purchases, and crashes from your Android app, once the SDK is published.

Android

How the Android SDK works

One library for Android apps, in Kotlin and usable from Java. Set it up once and installs, opens, screens, taps, links, notifications, Play purchases, crashes and ANRs are captured with no other code.

SettingValue
HostYour project's tracking hostname, such as https://m.example.com, from Setup
KeyThe ingest key (mpk_) of an Android source, from Setup. It ships in the app, so it can only send events.
SystemsAndroid 5.0 (API 21) or later
DeliveryQueued on the device, sent every 10 seconds, at 50 events and when the app goes to the background, retried with the same event ids so nothing is lost or counted twice
Android

Install and set up

Once the library is published, add it to your build and call setup in your Application.

Not available yet. The native Android SDK isn't published yet, so there is no package to install. To measure an Android app today, use the Kotlin Multiplatform SDK, which is published for Android. Its install steps will be listed here once this one is.
kotlin
class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Mode.setup(this, ModeConfig.Builder("YOUR_INGEST_KEY", "https://m.example.com").build())
    }
}

From Java the same call is Mode.setup(this, ModeConfig.builder("YOUR_INGEST_KEY", "https://m.example.com").build()).

Android

What is captured on its own

Every event lands in the same reports as your site's and your iOS app's, with the same people and sessions.

EventWhen
$app_installedThe first launch, with the version and build and the Play Install Referrer, so its campaign and the Mode click id reach every later event
$app_updatedThe first launch of a new version or build, with the previous one
$app_openedA cold launch, with how long it took to start, and every return to the foreground, with how long the app was away and the link or notification that opened it
$app_backgroundedThe app left the screen, with how long it was in use
$screenAn activity or fragment appeared, or a Navigation destination changed, with the screen before it and how long it was shown
$click, $rage_clickA tap on a button, switch, check box, list row or Compose control, and three fast taps in one place
$deep_link_openedAn App Link or a custom scheme link opened the app, with the app that sent it. Its UTM parameters, the Mode click id and sub ids are kept, so later signups and purchases are credited to the campaign
$push_received, $push_openedA notification arrived, or the person opened one, with its message id, campaign and channel
$push_registered, $permission_changeThe app got a push token, and notifications were turned on or off
$purchase, $subscription_startedGoogle Play purchases and subscriptions, each stored once even when Google's notifications report it too
$exceptionCrashes, ANRs and, on Android 11 and later, the last run's native crashes and system ANRs, with the screens and events before them

The first event of each session also carries the device (model, Android version, display, dark mode, text size, battery, network and the store the app came from). Every event carries the screen it happened on.

Android

Compose navigation and notifications

Two one line hookups cover what Android does not let a library find on its own.

kotlin
val nav = rememberNavController()
LaunchedEffect(nav) { Mode.trackNavController(nav) }

For notifications, register com.gotmode.metrics.ModeMessagingService as your Firebase messaging service, or call Mode.pushReceived(message) and Mode.registerPushToken(token) from your own. Notifications Firebase shows itself are seen when they open the app.

Android

Your own events and people

Add what only your app knows, and tie the device to the person once they sign in.

kotlin
Mode.capture("order_placed", mapOf("plan" to "pro", "items" to 3))
Mode.identify("user_123", set = mapOf("plan" to "pro"))
Mode.group("company", "acme")
Mode.register(mapOf("app_flavor" to "pro"))
Mode.reset()   // on sign out

A different user on the same device starts a new person, two users are never merged. setPersonProperties and unsetPersonProperties change the person before or after sign in, and registerOnce and registerForSession keep properties on every event, once or for the session.

Android

Feature flags

Read your project's flags in the app. They load at launch, after sign in and after group and property changes, and are kept for the next launch.

kotlin
if (Mode.isFeatureEnabled("new-checkout")) { ... }
val variant = Mode.getFeatureFlag("price-test") as? String
Mode.onFeatureFlags { flags -> ... }
Android

Purchases

When your app uses Play Billing, purchases are read on their own each time the app opens. To record one the moment it happens, and for consumables, pass it from your purchase listener too. It is still stored once.

kotlin
override fun onPurchasesUpdated(result: BillingResult, purchases: List<Purchase>?) {
    purchases?.forEach { Mode.capturePurchase(it) }
}
Android

What is never sent

The SDK collects what the app does, not what people type or keep.

Never sent, the content of any text field, notification titles and bodies, the advertising id, accounts, phone numbers, purchase tokens, or a property whose name reads as a secret. Links lose sign in tokens, codes, passwords and keys before they are kept, and email addresses become [email].

Let AI run your marketing.

Mode Agent does the daily work. You approve the spend.

Get early access