Setgreet Android SDK allows you to show Setgreet flows in your Android app.
- Android 5.0 (API level 21) and above
Add mavenCentral() to your project's build.gradle.kts file:
allprojects {
repositories {
mavenCentral()
}
}Add the following to your app's build.gradle.kts file:
dependencies {
implementation("com.setgreet:setgreet:LATEST_VERSION")
}- Setgreet App Key: You can find your App Key at Apps page.
Initialize the SDK in your Application class or where you want:
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Setgreet.initialize(
context = this,
appKey = "APP_KEY",
config = SetgreetConfig(
debugMode = false
)
)
}
}Identifies a user for Setgreet analytics and flow management.
Parameters:
userId(String): The unique identifier for the userattributes(Optional): Additional user attributesoperation(Optional): The operation type for user attributes (CREATE or UPDATE)locale(Optional): User's locale (e.g., "en-US"). If not provided, uses device's default locale
Example:
Setgreet.identifyUser(
userId = "user123",
attributes = mapOf(
"name" to "John Doe",
"email" to "john@example.com",
"plan" to "premium"
),
operation = Operation.CREATE,
locale = "en-US"
)Clears user identification data and resets user session state for logout scenarios.
Example:
Setgreet.resetUser()- Setgreet Flow ID: The flow ID is a unique identifier for the flow you want to show. You can get the flow ID from the flow's URL at the web app. For example, if the flow URL is
https://app.setgreet.com/flows/1234, the flow ID is1234.
To show the Setgreet flow, call the following method:
Setgreet.showFlow(flowId = "FLOW_ID")Tracks a screen view for analytics and potential flow triggers.
Parameters:
screenName(String): The name of the screen being viewedproperties(Optional): Additional properties associated with the screen view
Example:
Setgreet.trackScreen(
screenName = "product_detail",
properties = mapOf(
"product_id" to "prod_123",
"category" to "electronics",
"price" to 299.99
)
)Tracks custom events for analytics and flow triggers.
Parameters:
eventName(String): The name of the custom eventproperties(Optional): Additional properties associated with the event
Example:
Setgreet.trackEvent(
eventName = "purchase_completed",
properties = mapOf(
"order_id" to "ord_456",
"total_amount" to 299.99,
"payment_method" to "credit_card",
"items_count" to 3
)
)The SDK provides callbacks for monitoring flow lifecycle events.
Setgreet.setFlowCallbacks {
onFlowStarted { event ->
Log.d("Setgreet", "Flow ${event.flowId} started with ${event.screenCount} screens")
}
onFlowCompleted { event ->
// User completed the flow (reached last screen)
Analytics.log("flow_completed", mapOf(
"flow_id" to event.flowId,
"duration_ms" to event.durationMs
))
}
onFlowDismissed { event ->
// User dismissed the flow before completion
Log.d("Setgreet", "Flow dismissed: ${event.reason} at screen ${event.screenIndex + 1}")
}
onScreenChanged { event ->
Log.d("Setgreet", "Screen changed: ${event.fromIndex + 1} -> ${event.toIndex + 1}")
}
onActionTriggered { event ->
// User tapped a button - includes custom events from dashboard
event.actionName?.let { customEvent ->
Analytics.log(customEvent)
}
}
onPermissionRequested { event ->
Log.d("Setgreet", "Permission ${event.permissionType}: ${event.result}")
}
onError { event ->
Log.e("Setgreet", "Error: ${event.errorType} - ${event.message}")
}
}| Event | Description | Key Properties |
|---|---|---|
FlowStarted |
Flow begins presenting | flowId, screenCount |
FlowCompleted |
User completes the flow | flowId, durationMs |
FlowDismissed |
Flow dismissed before completion | flowId, reason, screenIndex |
ScreenChanged |
User navigates between screens | fromIndex, toIndex |
ActionTriggered |
Button action triggered | actionType, actionName |
PermissionRequested |
Permission request completed | permissionType, result |
FlowError |
Error during flow operations | errorType, message |
| Type | Description |
|---|---|
notification |
Push notification permission |
location |
Location access permission |
camera |
Camera access permission |
| Result | Description |
|---|---|
granted |
Permission was granted by the user |
denied |
Permission was denied by the user |
permanently_denied |
Permission was permanently denied |
already_granted |
Permission was already granted |
not_required |
Permission request was not required |
USER_CLOSE- User tapped the close buttonUSER_SKIP- User tapped the skip buttonBACK_PRESS- User pressed the back buttonREPLACED- Flow was replaced by another flowPROGRAMMATIC- Flow was closed programmatically