Android SDK
Kotlin SDK for tracking user events, managing identities, and handling consent in Android applications.
Android SDK
The Intempt Android SDK is a Kotlin library for tracking user events, managing user identification, and handling consent in Android applications.
Installation
Add the dependency to your build.gradle:
dependencies {
implementation 'com.intempt:android-sdk:latest'
}Configuration
Create an intempt-config.json file in your assets/ folder:
{
"organization": "your-org",
"project": "your-project",
"sourceId": "your-source-id",
"apiKey": "your-api-key",
"isLoggingEnabled": false,
"isTouchEnabled": true,
"isTextCaptureEnabled": true,
"queueEnabled": true,
"itemsInQueue": 5,
"timeBuffer": 5
}| Field | Type | Description |
|---|---|---|
organization | string | Organization identifier |
project | string | Project identifier |
sourceId | string | Source ID for data transmission |
apiKey | string | API key |
isLoggingEnabled | boolean | Enable debug logging |
isTouchEnabled | boolean | Enable touch event auto-capture |
isTextCaptureEnabled | boolean | Enable text capture in events |
queueEnabled | boolean | Enable event batching |
itemsInQueue | int | Batch size threshold |
timeBuffer | int | Seconds between batch sends |
Initialization
Call initialize() in your Application class onCreate() method:
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Intempt.initialize(this)
}
}User Tracking Control
Tracking.start()
Enables event tracking for the current user.
Intempt.Tracking.start()Tracking.stop()
Disables event tracking for the current user.
Intempt.Tracking.stop()Tracking.isTrackingEnabled()
Returns Boolean — whether tracking is currently active.
if (Intempt.Tracking.isTrackingEnabled()) {
Intempt.track("Button Click", mapOf("button" to "signup"))
}User Identification
identify()
Associates user actions with a specific user ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | String | Yes | Unique user identifier |
eventTitle | String | No | Custom event name (default: "Identify") |
userAttributes | Map<String, Any> | No | User properties |
data | Map<String, Any> | No | Supplementary event data |
Intempt.identify(
userId = "user123",
eventTitle = "User Registration",
userAttributes = mapOf(
"email" to "user@example.com",
"name" to "John Doe",
"plan" to "premium"
),
data = mapOf(
"registrationSource" to "app",
"referrer" to "google"
)
)alias()
Links two distinct user identifiers together.
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | String | Yes | Primary user identifier |
anotherUserId | String | Yes | Secondary identifier to alias |
Intempt.alias(
userId = "anonymous_123",
anotherUserId = "authenticated_user456"
)Group / Account
group()
Connects a user with a group or business account.
| Parameter | Type | Required | Description |
|---|---|---|---|
accountId | String | Yes | Account/group identifier |
eventTitle | String | No | Custom event label |
accountAttributes | Map<String, Any> | No | Account properties |
Intempt.group(
accountId = "company_abc",
eventTitle = "Account Created",
accountAttributes = mapOf(
"name" to "Acme Corp",
"plan" to "enterprise",
"employees" to 500
)
)Event Tracking
track()
Records a custom event with associated data.
| Parameter | Type | Required | Description |
|---|---|---|---|
eventTitle | String | Yes | Event name |
data | Map<String, Any> | Yes | Event data |
Intempt.track(
eventTitle = "Purchase Completed",
data = mapOf(
"orderId" to "order_123",
"amount" to 99.99,
"currency" to "USD"
)
)record()
Captures an event with optional user and account context.
| Parameter | Type | Required | Description |
|---|---|---|---|
eventTitle | String | Yes | Event name |
userId | String | No | User identifier |
accountId | String | No | Account identifier |
userAttributes | Map<String, Any> | No | User properties |
accountAttributes | Map<String, Any> | No | Account properties |
data | Map<String, Any> | No | Supplementary event data |
Intempt.record(
eventTitle = "Feature Used",
userId = "user123",
accountId = "account456",
data = mapOf("feature" to "dashboard", "duration" to 300),
userAttributes = mapOf("role" to "admin"),
accountAttributes = mapOf("plan" to "enterprise")
)Consent Management
consent()
Registers user consent preferences.
| Parameter | Type | Required | Description |
|---|---|---|---|
action | String | Yes | "accept" or "reject" |
validUntil | Long | Yes | Expiration timestamp (Unix) |
email | String | No | User email |
message | String | No | Consent statement |
category | String | No | Consent classification |
Intempt.consent(
action = "accept",
validUntil = System.currentTimeMillis() + (365L * 24 * 60 * 60 * 1000),
email = "user@example.com",
category = "analytics"
)Product Tracking
productAdd()
Logs when a product is added to the cart.
Intempt.productAdd(productId = "prod_123", quantity = 2)productOrdered()
Records products purchased at checkout.
Intempt.productOrdered(listOf(
mapOf("productId" to "prod_123", "quantity" to 2),
mapOf("productId" to "prod_456", "quantity" to 1)
))productView()
Captures when a product screen is viewed.
Intempt.productView(productId = "prod_123")Session Management
logOut()
Clears session data while preserving the profile ID.
Intempt.logOut()Recommendations
recommendation()
Fetches personalized product recommendations. Must be called from a coroutine.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Int | Yes | Feed identifier |
quantity | Int | Yes | Number of recommendations |
fields | List<String> | Yes | Fields to return |
lifecycleScope.launch {
val result = Intempt.recommendation(
id = 123,
quantity = 10,
fields = listOf("productId", "name", "price", "image")
)
result?.let { recommendations ->
// handle recommendations
}
}Privacy — Protecting Sensitive Views
Use doNotCaptureText() to exclude views containing sensitive information from text capture:
val sensitiveView = findViewById<EditText>(R.id.password_field)
Intempt.doNotCaptureText(sensitiveView)Experiments & Personalization
// Fetch experiment variation
val experiment = Intempt.experiment.choose("experiment-name")
// Fetch personalization
val personalization = Intempt.personalization.choose("personalization-name")Forbidden Event Titles
These titles are reserved and will throw an error:
auto-track · view page · leave page · change on · click on · submit on · identify · consent
All tracking methods silently return without executing when the user has opted out of tracking.
