API Reference
AttributeHQ Class
Singleton accessed via AttributeHQ.shared.
initialize(configuration:) throws
Initialize the SDK. Must be called before any other method.
let config = AttributeHQConfiguration(
apiKey: "ak_your_api_key",
appId: "your-app-uuid",
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"]
)| Parameter | Type | Default | Description |
|---|---|---|---|
eventName | String | — | 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"]
)| Parameter | Type | Default | Description |
|---|---|---|---|
amount | Double | — | Revenue amount |
currency | String | "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: ["email": "user@example.com"]
)flush()
Immediately send all queued events.
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)")
}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 = true
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: TimeInterval?
}MatchType
enum MatchType: String {
case deviceId = "device_id"
case fingerprint = "fingerprint"
case organic = "organic"
}AttributeHQError
enum AttributeHQError: Error {
case invalidConfiguration(String)
}