Intempt Android SDK API Documentation#
Overview#
Intempt Android SDK is a Kotlin SDK for tracking user events, managing user identification, and handling consent management in Android applications. This document describes all public methods available in the Intempt object.Initialization#
initialize(context: Context)#
Initializes the Intempt SDK with the application context. This method must be called before using any other SDK methods, typically in your Application class's onCreate() method.| Parameter | Type | Required | Description |
|---|
context | Context | Yes | Application context |
The SDK requires a configuration file intempt-config.json in your assets folder with the following structure:{
"auth": {
"INTEMPT_API_KEY": "username.password",
"INTEMPT_SOURCE_ID": "your-source-id",
"INTEMPT_ORGANIZATION_ID": "your-organization-id",
"INTEMPT_PROJECT_ID": "your-project-id"
},
"options": {
"isLoggingEnabled": false,
"isTouchEnabled": true,
"isTextCaptureEnabled": true,
"isQueueEnabled": true,
"isAutoCaptureEnabled": true,
"itemsInQueue": 5,
"timeBuffer": 5000
}
}
| Option | Type | Default | Description |
|---|
isLoggingEnabled | Boolean | false | Enable SDK logging |
isTouchEnabled | Boolean | true | Enable automatic touch event tracking |
isTextCaptureEnabled | Boolean | true | Enable automatic text capture |
isQueueEnabled | Boolean | true | Enable event queuing |
isAutoCaptureEnabled | Boolean | true | Enable automatic event capture |
itemsInQueue | Int | 5 | Number of events to queue before sending |
timeBuffer | Long | 5000 | Time buffer in milliseconds for event batching |
Note: If initialization fails, an error message will be printed to the console, but the app will continue to run.
User Tracking Control Methods#
Tracking.start()#
Enables tracking for the current user.
Tracking.stop()#
Disables tracking for the current user.
Tracking.isTrackingEnabled()#
Checks if the user has opted in to tracking.Returns: Boolean - true if tracking is enabled, false otherwise
Logging Control Methods#
Logging.start()#
Logging.stop()#
Logging.isLoggingEnabled()#
Checks if logging is currently enabled.Returns: Boolean - true if logging is enabled, false otherwise
User Identification Methods#
identify(userId: String, eventTitle: String? = null, userAttributes: Map<String, String>? = null, data: Map<String, String>? = null)#
Identifies a user and associates them with a user ID. This method is used to link user actions to a specific user identity.| Parameter | Type | Required | Description |
|---|
userId | String | Yes | Unique identifier for the user |
eventTitle | String? | No | Custom event title (default: "Identify") |
userAttributes | Map<String, String>? | No | User attributes map (requires eventTitle if provided) |
data | Map<String, String>? | No | Additional event data |
If userAttributes is provided, eventTitle must also be provided
Forbidden event titles: "auto-track", "view page", "leave page", "change on", "click on", "submit on", "identify", "consent"
alias(userId: String, anotherUserId: String)#
Creates an alias between two user IDs. Used when a user is identified with different IDs (e.g., anonymous ID and authenticated ID).| Parameter | Type | Required | Description |
|---|
userId | String | Yes | Primary user ID |
anotherUserId | String | Yes | Secondary user ID to alias |
Group/Account Methods#
group(accountId: String, eventTitle: String? = null, accountAttributes: Map<String, String>? = null)#
Associates a user with a group or account.| Parameter | Type | Required | Description |
|---|
accountId | String | Yes | Unique identifier for the account/group |
eventTitle | String? | No | Custom event title (default: "Identify") |
accountAttributes | Map<String, String>? | No | Account attributes map (requires eventTitle if provided) |
accountId must not be empty
If accountAttributes is provided, eventTitle must also be provided
Forbidden event titles: same as identify method
Event Tracking Methods#
track(eventTitle: String, data: Map<String, String>)#
Tracks a custom event with associated data.| Parameter | Type | Required | Description |
|---|
eventTitle | String | Yes | Name of the event |
data | Map<String, String> | Yes | Event data map (must not be empty) |
eventTitle is required and must not be empty
data must be provided and non-empty
Forbidden event titles: same as identify method
record(eventTitle: String, accountId: String? = null, userId: String? = null, accountAttributes: Map<String, String>? = null, userAttributes: Map<String, String>? = null, data: Map<String, String>? = null)#
Records an event with optional user and account information.| Parameter | Type | Required | Description |
|---|
eventTitle | String | Yes | Name of the event |
accountId | String? | No | Account identifier |
userId | String? | No | User identifier |
accountAttributes | Map<String, String>? | No | Account attributes |
userAttributes | Map<String, String>? | No | User attributes |
data | Map<String, String>? | No | Additional event data |
Forbidden event titles: same as identify method
Consent Management#
consent(action: String, validUntil: Long, email: String? = null, message: String? = null, category: String? = null)#
Records user consent preferences.| Parameter | Type | Required | Description |
|---|
action | String | Yes | Consent action ("accept" or "reject") |
validUntil | Long | Yes | Timestamp when consent expires (Unix timestamp in milliseconds) |
email | String? | No | User email address |
message | String? | No | Consent message |
category | String? | No | Consent category |
action must be either "accept" or "reject"
validUntil is required (Unix timestamp in milliseconds)
Product Tracking Methods#
productAdd(productId: String, quantity: Int)#
Tracks when a product is added to cart.| Parameter | Type | Required | Description |
|---|
productId | String | Yes | Product identifier |
quantity | Int | Yes | Quantity added |
Event Title: "Added to cart"
productOrdered(products: List<Map<String, Any>>)#
Tracks when products are ordered (purchased).| Parameter | Type | Required | Description |
|---|
products | List<Map<String, Any>> | Yes | List of product maps, each containing productId (String) and quantity (Int) |
Each product map must contain:productId: String (required, non-empty)
quantity: Int (required, must be > 0)
Event Title: "Product ordered"
productView(productId: String)#
Tracks when a product is viewed.| Parameter | Type | Required | Description |
|---|
productId | String | Yes | Product identifier |
Event Title: "Product viewed"
Session Management#
logOut()#
Handles user logout by clearing session data and refreshing the auto tracker.Note: This method only executes if the user has opted in to tracking. The profile ID is preserved after logout.
Recommendation API#
recommendation(id: String, quantity: Int, fields: List<String>, productId: String?): JsonObject?#
Fetches product recommendations from the Intempt API. This is a suspend function and must be called from a coroutine.| Parameter | Type | Required | Description |
|---|
id | String | Yes | Feed ID for recommendations |
quantity | Int | Yes | Number of recommendations to return |
fields | List<String> | Yes | Fields to include in the response |
productId | String? | No | Optional product ID for context |
Returns: JsonObject? - Recommendation data or null on errorEndpoint: {api}/{organization}/projects/{project}/feeds/{id}/data
Authentication: Basic Auth (derived from API key in config)
Returns null if the request fails
Errors are logged if logging is enabled
Experiments and Personalization#
experiment: ModificationProvider#
Provides access to server-side experiments. Use this to fetch experiment variations.getByGroup(data: List<String>): JsonElement? (suspend)#
Fetches experiments by group names.getByName(data: List<String>): JsonElement? (suspend)#
Fetches experiments by experiment names.getByGroupAsync(data: List<String>): CompletableFuture<JsonElement?>#
Asynchronous version of getByGroup for Java interop.getByNameAsync(data: List<String>): CompletableFuture<JsonElement?>#
Asynchronous version of getByName for Java interop.
personalization: ModificationProvider#
Provides access to server-side personalization campaigns. Use this to fetch personalized content.Same as experiment - getByGroup, getByName, getByGroupAsync, getByNameAsync.
Privacy and Data Capture#
doNotCaptureText(view: View)#
Marks a view to exclude its text content from automatic capture. This is useful for sensitive data like passwords or personal information.| Parameter | Type | Required | Description |
|---|
view | View | Yes | View to exclude from text capture |
Note: If an unsupported view type is passed, an error will be logged.
Common Behavior#
Opt-In Requirement#
Most tracking methods (identify, group, track, record, alias, consent, productAdd, productOrdered, productView, logOut) will silently return without executing if the user has opted out of tracking. Use Tracking.isTrackingEnabled() to check the current status.Automatic IDs#
The following IDs are automatically included in all tracking events:profileId: Generated/retrieved from storage
sessionId: Current session identifier
pageId: Current page identifier
Automatic Event Capture#
The SDK automatically captures:Screen views (Activity lifecycle events)
Touch events (clicks, taps)
Form changes (text input changes)
App install/upgrade events
This behavior can be controlled via configuration options in intempt-config.json.Forbidden Event Titles#
The following event titles are forbidden and will cause validation errors:
Error Handling#
All validation errors are logged using the SDK's logging system. Common errors include:Configuration errors: Missing or invalid configuration file
Parameter validation errors: Missing required parameters or invalid values
Field-specific errors: Specific field validation failures
Forbidden event titles: Attempting to use reserved event titles
Errors are logged but do not throw exceptions, allowing your app to continue running. Enable logging with Intempt.Logging.start() to see error messages.
Best Practices#
1.
Initialize early: Call Intempt.initialize() in your Application.onCreate() method before any other SDK calls.
2.
Check tracking status: Before tracking, check if the user has opted in: 3.
Use coroutines for async operations: Methods like recommendation() and modification providers are suspend functions. Use coroutines: 4.
Protect sensitive data: Use doNotCaptureText() for views containing sensitive information like passwords or credit card numbers.
5.
Configure appropriately: Set up your intempt-config.json file with appropriate options for your use case.
6.
Respect user consent: Always respect user consent preferences and use the consent() method to record consent decisions.
7.
Handle null results: Async methods like recommendation() and modification providers can return null on error. Always check for null before using results.
Type Definitions#
Configuration File Structure#
{
"auth": {
"INTEMPT_API_KEY": "string",
"INTEMPT_SOURCE_ID": "string",
"INTEMPT_ORGANIZATION_ID": "string",
"INTEMPT_PROJECT_ID": "string"
},
"options": {
"isLoggingEnabled": boolean,
"isTouchEnabled": boolean,
"isTextCaptureEnabled": boolean,
"isQueueEnabled": boolean,
"isAutoCaptureEnabled": boolean,
"itemsInQueue": number,
"timeBuffer": number
}
}
ModificationProvider Interface#
SDK Version: See BuildConfig.sdkVersion in your build
Documentation Version: 1.0.0
Additional Resources#
Modified at 2025-11-26 16:38:45