Skip to content
trackd.one

Apps

Android (Kotlin)

Privacy-first analytics for Android apps and games. Kotlin, zero third-party dependencies, Android 5.0+.

Overview

  • No ANDROID_ID, no advertising id, no device model, no install id — nothing persistent.
  • Nothing is written to disk (no SharedPreferences, files or database). Events and the session id live in memory only.
  • Events are batched and sent from a background thread with a neutral User-Agent: trackd-android/<version>. The SDK catches everything and never crashes your app.

Requirements: minSdk 21 (Android 5.0), Kotlin 1.9+ / 2.x. Java callers are supported.

Install

The Maven Central artifact is coming. Until then:

  1. Download Trackd.kt to app/src/main/java/one/trackd/sdk/Trackd.kt.
  2. Make sure your manifest has the internet permission — also for release builds:
<uses-permission android:name="android.permission.INTERNET" />

You can also include the sdk/android/ folder as a Gradle module.

Initialize

import one.trackd.sdk.Trackd

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Trackd.init(this, "YOUR_WEBSITE_ID", debug = BuildConfig.DEBUG)
        // self-hosted: Trackd.init(this, "YOUR_WEBSITE_ID", host = "https://stats.example.com")
    }
}

Register the class in the manifest (<application android:name=".MyApp" …>). In the dashboard, create a project with your application id (e.g. com.example.mygame) as domain.

API

Trackd.screen("Home")                              // screen view (alias: screenView)
Trackd.screen("Settings/Profile", "Profile")       // with title
Trackd.event("signup", mapOf("plan" to "pro", "trial" to true))
Trackd.revenue(4.99, "EUR", "order-123")           // → event "purchase"
Trackd.flush()                                     // send now (async)
Trackd.setEnabled(false)                           // opt-out: stop + clear queue

// Game & media helpers
Trackd.gameStart(level = 1, mode = "hard")
Trackd.levelComplete(level = 5, score = 1200, timeMs = 45_000)
Trackd.gameOver(level = 3, reason = "fell")
Trackd.videoWatch("intro", durationMs = 30_000, completed = true)
Trackd.adView("rewarded", "ad-1")
Trackd.tutorialStep(step = 2, total = 5, skipped = false)

Event data must be flat (String, Number, Boolean), max. 4 KB.

Screens with Jetpack Compose

@Composable
fun HomeScreen() {
    LaunchedEffect(Unit) { Trackd.screen("Home") }
}

For Navigation Compose, add a NavController.OnDestinationChangedListener and call Trackd.screen(destination.route) — route templates like profile/{id}, never user data. With Activities/Fragments call Trackd.screen() in onResume().

Batching, retries & sessions

  • Flush at 20 queued events, 30 s after an event, on flush() and when the app goes to the background.
  • Max. 50 events / 60 KB per request, max. 500 queued events (oldest dropped).
  • Network errors, 5xx, 408, 429 → exponential backoff (1 s … 5 min, honors Retry-After), same batch_id so the server drops duplicates.
  • Session id: 20 random chars, memory only, rotated after 30 min without events or in the background.

Google Play Data safety

Declare App activity → App interactions (plus Other actions with revenue) and Location → Approximate location (country, derived server-side), purpose Analytics, not shared, encrypted in transit. Device or other IDs: not collected. Whether your app needs consent has to be assessed for your app — see Privacy & GDPR.

Ready in minutes

Create a free account, add your website or app, copy the snippet.

Start for free