Skip to main content

Android SDK

The JourneyLayer Android SDK is a Kotlin library (current version 1.1.0) that tracks events, identifies users, and powers on-device capabilities such as push notifications, in-app messages, and deep links.

It exposes the same three core methods you know from the web: track, identify, and reset.

Source of truth

This page gets you installed and sending events. For the exact, current initialization signature, builder options, and the push / in-app / deep-link APIs, always confirm against the Android SDK source on GitHub. We keep the in-repo README authoritative so you never copy a stale signature.

Installation

The SDK is distributed via JitPack.

1. Add the JitPack repository

In your settings.gradle(.kts) (or root build.gradle for older projects), add JitPack to your dependency repositories:

// settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}

2. Add the Gradle dependency

In your app module's build.gradle(.kts):

dependencies {
implementation("com.github.digitalgw.journeylayer:android:1.1.0")
}
Confirm the exact coordinate

The coordinate above is illustrative. Confirm the exact group/artifact path and the latest version in the Android SDK README.

Initialization

Initialize the SDK once, early in your app lifecycle (typically your Application.onCreate()). You need three things:

  • Project ID — your project's public ID, from the dashboard.
  • Publishable token — the publishable browser/mobile token. This is safe to embed in your app config.
  • Events endpoint — defaults to https://collect.journeylayer.com/v1/events, or your first-party tracker domain (e.g. https://track.yourdomain.com/v1/events) if you've set one up.
import android.app.Application
import com.journeylayer.android.JourneyLayer

class MyApp : Application() {
override fun onCreate() {
super.onCreate()

JourneyLayer.init(
context = this,
projectId = "<PROJECT_PUBLIC_ID>",
token = "<PUBLISHABLE_TOKEN>",
endpoint = "https://collect.journeylayer.com/v1/events"
)
}
}
Use the publishable token only

Embed the publishable browser/mobile token in your app. Never ship the server project token in a mobile binary — it can be extracted from the APK.

Confirm the init signature

The snippet above is illustrative. The exact parameter names and any builder / config object are defined in the Android SDK README.

Track events

Record a custom event with track(name, properties). Event names are free-form and auto-register on the server, so there's no schema to define first.

JourneyLayer.track(
"Product Viewed",
mapOf(
"product_id" to "SKU-123",
"price" to 1499,
"currency" to "INR"
)
)
  • name — a human-readable string. Title Case (Product Viewed) is a good convention.
  • properties — a map of JSON-serializable values. Send whatever you'll want to segment and filter on later.

Identify users

Tie the current device to a known person with identify(traits). Call it once you know who the user is, for example right after login.

JourneyLayer.identify(
mapOf(
"identity" to "[email protected]", // stable id, usually email
"email" to "[email protected]",
"name" to "Kishan",
"phone" to "+91 9999999999"
)
)

The stable identity stitches the device's earlier anonymous activity to the known user.

Reset on logout

Call reset() on logout so the next user on a shared device isn't merged into the previous one. It clears the identity and starts a fresh anonymous id.

JourneyLayer.reset()

Updating the SDK

To update, bump the version in your Gradle dependency and resync:

implementation("com.github.digitalgw.journeylayer:android:1.1.0")

Check the Android SDK README for the latest released version and any migration notes.

Next