Track Events
Capture how users interact with your app.
Log custom events with a single call and attach a property map — strings, numbers, booleans — for full context on every interaction.
A lightweight Kotlin SDK that captures every event and session, tracks FCM & HMS push, and works offline — streaming it all into B2Metric IQ for funnels, retention and churn.
import android.app.Application
import com.b2metric.analytics.B2MetricSDK
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
B2MetricSDK.init(
context = this,
apiKey = "YOUR_API_KEY",
batchSize = 20,
flushInterval = 30
)
}
}Quick start
Add the Gradle dependency, initialize in your Application class, and log your first event.
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
maven { url = uri("https://github.com/b2metric") }
}
}
// app/build.gradle.kts
dependencies {
implementation("com.b2metric:analytics-android:1.0.1")
}Capabilities
One install captures the full picture — automatic baselines plus precise, typed events you control.
Capture how users interact with your app.
Log custom events with a single call and attach a property map — strings, numbers, booleans — for full context on every interaction.
Lifecycle events, with zero code from you.
The SDK automatically tracks key lifecycle events — app opens, sessions and activity transitions — so you get a behavioral baseline out of the box.
Measure delivery and engagement.
Built-in support for Firebase Cloud Messaging and Huawei Mobile Services attributes notification delivery and opens to downstream behavior.
Battery- and network-friendly by design.
Events are queued and sent in batches to optimize battery life and network usage. Tune batchSize and flushInterval to fit your app.
Never lose an event off-grid.
Events captured while the device is offline are persisted locally and flushed automatically once connectivity returns.
Verify your integration in real time.
Raise the log level to stream every event and network call to Logcat while developing, then silence it for release builds.
Configuration
Three parameters control everything. Send events instantly while debugging, then batch for battery and network efficiency in release builds.
| Parameter | Default | Type |
|---|---|---|
| apiKeyREQUIRED Your B2Metric API key. Must be non-empty. | — | String |
| batchSize Number of events to batch before sending. | 20 | Int |
| flushInterval Time in seconds between automatic flushes. | 30 | Long |
B2MetricSDK.setLogLevel(LogLevel.DEBUG)
B2MetricSDK.init(
context = this,
apiKey = "YOUR_DEV_API_KEY",
batchSize = 1, // send immediately
flushInterval = 5
)Event payload
Call logEvent with a name and typed properties — the SDK enriches every payload before it leaves the device.
{
"api_key": "sdk_xxxxxxxxxxxxxxxx",
"body": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "product_viewed",
"timestamp": "2026-02-18T07:45:02.552Z",
"properties": {
"product_id": "SKU-123",
"product_name": "Running Shoes",
"category": "Footwear",
"price": 299.90
},
"user_properties": {
"app_version": "1.0.1",
"device_model": "Pixel 8 Pro",
"os_version": "14",
"platform": "Android",
"country_code": "TR",
"timezone": "Europe/Istanbul"
}
}
}Documentation
From installation to troubleshooting — every page in the B2Metric Academy Android guide.
Add the package, paste your API key, and watch events arrive in B2Metric IQ in real time.
Copyright © 2025 B2Metric | All Rights Reserved
Copyright © 2025 B2Metric | All Rights Reserved
Copyright © 2025 B2Metric | All Rights Reserved
Check your network and try again.