API Reference
AttributeHQ Object
Singleton accessed directly as AttributeHQ.
initialize(context: Context, configuration: AttributeHQConfiguration)
Initialize the SDK. Must be called before any other method.
val config = AttributeHQConfiguration(
apiKey = "ak_your_api_key",
appId = "your-app-uuid",
enableDebugLogging = true
)
AttributeHQ.initialize(applicationContext, config)| Parameter | Type | Description |
|---|---|---|
context | Context | Application context |
configuration | AttributeHQConfiguration | SDK configuration |
track(eventName: String, properties: Map<String, Any?> = emptyMap())
Track a custom event.
AttributeHQ.track("purchase", mapOf("amount" to 1500, "currency" to "NGN"))trackRevenue(amount: Double, currency: String = "NGN", properties: Map<String, Any?> = emptyMap())
Track a revenue event.
AttributeHQ.trackRevenue(5000.0, "NGN", mapOf("product" to "premium"))identify(userId: String, properties: Map<String, Any?> = emptyMap())
Associate events with a known user.
AttributeHQ.identify("user_12345", mapOf("plan" to "premium"))flush()
Request a flush of queued events and enabled sandbox evidence. This is asynchronous and is a no-op while collection is disabled.
AttributeHQ.flush()getAttribution(): AttributionResult?
Get cached attribution result. Returns null if install tracking has not completed or collection is disabled.
val result = AttributeHQ.getAttribution()Types
AttributeHQConfiguration
data class AttributeHQConfiguration(
val apiKey: String,
val appId: String,
var batchSize: Int = 10,
var flushIntervalSeconds: Long = 5L,
var maxQueueSize: Int = 100,
var enableDebugLogging: Boolean = false,
var requestTimeoutMs: Long = 30_000L,
/** Null preserves stored state; a new installation collects after initialize by default. */
var initialCollectionEnabled: Boolean? = null,
/** Null preserves the stored preference; a new installation starts unknown. */
var initialAdvertisingSharing: AdvertisingSharing? = null,
/** Opt-in diagnostic transport only; never sends production postbacks. */
var enableSandboxEvidenceUpload: Boolean = false,
/** Separate app-level tracking decision; null preserves saved state, new installs default false. */
var initialApplicationTrackingEnabled: Boolean? = null
)AttributionResult
data class AttributionResult(
val matchType: MatchType,
val confidence: Int, // 0-100
val mediaSource: String?,
val campaignId: String?,
val isOrganic: Boolean,
val attributedTouchTime: Long? // Unix milliseconds
)AttributionResult.MatchType
enum class MatchType(val value: String) {
INSTALL_REFERRER("install_referrer"),
DEVICE_ID("device_id"),
FINGERPRINT("fingerprint"),
ORGANIC("organic")
}These names describe possible server results, not validation guarantees for each attribution path. See referrer validation limits.
Privacy and evidence methods
See privacy controls for examples, ordering, persistence failures and withdrawal limits.
| Method | Behavior |
|---|---|
getAppInstanceId(): String? | App-scoped random ID; null before available or when collection is disabled |
setCollectionEnabled(enabled: Boolean, completion: ((Boolean) -> Unit)? = null) | Apply collection choice in SDK order; disable purges pending telemetry |
isCollectionEnabled(): Boolean | Applied state, not a queued change; false before initialization |
setAdvertisingSharing(preference: AdvertisingSharing, completion: ((Boolean) -> Unit)? = null) | Persist the entire sharing choice and refresh enabled evidence |
getAdvertisingSharing(): AdvertisingSharing | Read applied local sharing choice |
setApplicationTrackingEnabled(enabled: Boolean, completion: ((Boolean) -> Unit)? = null) | Persist the app-level tracking decision; not a system permission |
refreshConversionEvidence() | Request a fresh observation if collection and sandbox evidence are enabled |
prepareConversionEvidence(eventId: String, completion: (Result<ConversionEvidenceTicket>) -> Unit) | Retain an immutable event-time ticket; repeated event ID returns its original ticket |
completeConversionEvidence(eventId: String, completion: ((Boolean) -> Unit)? = null) | Remove an acknowledged ticket after your authenticated backend durably accepts it |
Callbacks run on the main thread. A prepared ticket is local evidence, not a conversion receipt or delivery grant. ConversionEvidenceTicket.eventId exposes its ID and toJson() returns a copy. At most 100 tickets are retained.
AdvertisingSharing.Choice is UNKNOWN, ALLOWED or DENIED. AdvertisingSharing.Partner is META or X; restrictions only narrow sharing. Unknown cannot erase an earlier reported denial. Android partner delivery remains disabled.