Skip to Content

API Reference

AttributeHQ Class

Singleton accessed via AttributeHQ.shared.

initialize(configuration:) throws

Initialize the SDK. Must be called before any other method.

var config = AttributeHQConfiguration( apiKey: "ak_your_api_key", appId: "your-app-uuid" ) config.enableDebugLogging = true try AttributeHQ.shared.initialize(configuration: config)

Throws AttributeHQError.invalidConfiguration if apiKey or appId is empty.

track(eventName:properties:)

Track a custom event.

AttributeHQ.shared.track( eventName: "purchase", properties: ["amount": 1500, "currency": "NGN"] )
ParameterTypeDefaultDescription
eventNameString—Event name
properties[String: Any][:]Custom properties

trackRevenue(amount:currency:properties:)

Track a revenue event.

AttributeHQ.shared.trackRevenue( amount: 5000, currency: "NGN", properties: ["product": "premium"] )
ParameterTypeDefaultDescription
amountDouble—Revenue amount
currencyString"NGN"ISO 4217 currency code
properties[String: Any][:]Custom properties

identify(userId:properties:)

Associate events with a known user.

AttributeHQ.shared.identify( userId: "user_12345", properties: ["plan": "premium"] )

flush()

Request an asynchronous flush of queued events. This is not a server acknowledgement.

AttributeHQ.shared.flush()

getAttribution() -> AttributionResult?

Get cached attribution result. Returns nil if install tracking hasn’t completed.

let result = AttributeHQ.shared.getAttribution()

requestATTPermission(completion:)

Request App Tracking Transparency permission (iOS 14+).

AttributeHQ.shared.requestATTPermission { status in print("ATT status: \(status)") }

identify records an identification event; it does not by itself guarantee cross-device customer reconciliation. Use opaque customer IDs and avoid unnecessary personal data.

getAppInstanceId() -> String?

Returns the app-scoped installation UUID after initialization, or nil before it. This is not an advertising identifier.

Types

AttributeHQConfiguration

struct AttributeHQConfiguration { let apiKey: String let appId: String var enableDebugLogging: Bool = false var batchSize: Int = 10 var flushInterval: TimeInterval = 5 var maxQueueSize: Int = 100 var requestATTOnInit: Bool = false var attDelaySeconds: TimeInterval = 0 }

AttributionResult

struct AttributionResult { let matchType: MatchType // .deviceId, .fingerprint, .organic let confidence: Int // 0-100 let mediaSource: String? let campaignId: String? let isOrganic: Bool let attributedTouchTime: Int64? }

MatchType

enum MatchType: String { case deviceId = "device_id" case fingerprint = "fingerprint" case organic = "organic" }

AttributeHQError

enum AttributeHQError: Error { case invalidConfiguration(String) }