B2Metric Analytics · v1.0.1

Behavioral analytics for your Android app, in minutes.

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.

Android 5.0+ (API 21)Kotlin & JavaFCM · HMS
MyApp.kt
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
    )
  }
}
SDK initialized — events start flowing
LIVE · B2Metric SDK

Event stream

app_opened
AUTO
activity_resumed
CartActivity
AUTO
product_viewed
SKU-123
LOG
add_to_cart
$299.99
LOG
push_received
FCM
AUTO

Quick start

From zero to first event in three steps

Add the Gradle dependency, initialize in your Application class, and log your first event.

build.gradle.kts
// 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")
}
Add the dependency with Gradle

Capabilities

Everything you need to understand mobile behavior

One install captures the full picture — automatic baselines plus precise, typed events you control.

Core

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.

Automatic Event Tracking

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.

FCM · HMS

Push Notification Tracking

Measure delivery and engagement.

Built-in support for Firebase Cloud Messaging and Huawei Mobile Services attributes notification delivery and opens to downstream behavior.

Performance

Event Batching & Flushing

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.

Offline Support

Never lose an event off-grid.

Events captured while the device is offline are persisted locally and flushed automatically once connectivity returns.

Debug Mode

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

Tuned for development. Hardened for production.

Three parameters control everything. Send events instantly while debugging, then batch for battery and network efficiency in release builds.

ParameterDefaultType
apiKeyREQUIRED
Your B2Metric API key. Must be non-empty.
String
batchSize
Number of events to batch before sending.
20Int
flushInterval
Time in seconds between automatic flushes.
30Long
String "value"Int, Double 42, 3.14Boolean true, falseMap<String, Any> mapOf(...)
Development · MyApp.kt
B2MetricSDK.setLogLevel(LogLevel.DEBUG)
B2MetricSDK.init(
  context = this,
  apiKey = "YOUR_DEV_API_KEY",
  batchSize = 1,        // send immediately
  flushInterval = 5
)

Event payload

Rich context, attached automatically

Call logEvent with a name and typed properties — the SDK enriches every payload before it leaves the device.

  • Each event carries a unique id and ISO timestamp.
  • Your properties map passes through with full type fidelity.
  • user_properties — device, OS, app version, locale — are added for you.
product_viewed · payload.json
{
  "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"
    }
  }
}
$ ./gradlew :app:assembleB2MetricSDK.logEvent("purchase_completed")

Ship your first insight today.

Add the package, paste your API key, and watch events arrive in B2Metric IQ in real time.