Android (Kotlin)

Install the Android SDK and track app opens and screens.

Last updated June 3, 2026

Install the Android SDK, configure the site ID, and send app_open and screen_view events. Lifecycle events can be sent explicitly with trackEvent from Activity callbacks. See what the SDK can do →.

Prerequisites

  • A Grometrics site ID from Settings > Tracking
  • Access to the mobile app code
  • A debug build or simulator for verification

Steps

1

Add version 1.1.1

Add the tracker dependency to the app module.

app/build.gradle.kts

1dependencies {2  implementation("com.usegrometrics:grometrics-android:1.1.1")3}
2

Create and start the tracker

Keep one tracker instance in your Application or dependency container.

Replace YOUR_SITE_ID with your site ID from Settings > Tracking.

MainApplication.kt

1val grometrics = GrometricsTracker(2  applicationContext,3  GrometricsConfiguration(websiteId = "YOUR_SITE_ID")4)5grometrics.start()
3

Identify and reset

Identify after login and reset before another user can sign in on the device.

Auth.kt

1grometrics.identify(user.id)23// Before sign-out4grometrics.reset()5auth.signOut()
4

Track screens

Send a screen view from Activity, Fragment, or Compose destination changes.

CheckoutScreen.kt

1grometrics.trackScreen(2  name = "Checkout",3  path = "/checkout"4)

Options / Configuration

OptionTypeRequiredDescription
websiteIdstringYour Grometrics site ID
appVersionstringnoPopulates app version filters

What happens next

Run a debug build and confirm app_open and screen_view events in Realtime.

Verify your setup

Verify your setup

Troubleshooting

No event appears

Confirm the site ID matches Settings > Tracking and that the latest published code is running.

Was this page helpful?