Receive attribution data in your app
When Adapty matches an install to a campaign, it returns attribution data to your app in the onInstallationDetailsSuccess callback. Use this data to personalize the user experience based on the channel or campaign that drove the install.
Starting from Adapty SDK version 4.1, Adapty Attribution is disabled by default. The onInstallationDetailsSuccess callback fires only after you enable Adapty Attribution when activating the SDK.
The attribution data is returned as a nested attribution object inside the payload field. It contains the following fields:
| Field | Description |
|---|---|
channel | Acquisition channel (e.g. facebook, tiktok, google, organic) |
campaign_id | Campaign identifier |
campaign_name | Campaign name |
adset_id | Ad set / ad group identifier |
adset_name | Ad set / ad group name |
ad_id | Ad / creative identifier |
ad_name | Ad / creative name |
All fields are optional. For organic installs or when attribution could not be determined, the payload field does not include the attribution object.
To read attribution data in your app:
Adapty.delegate = self
nonisolated func onInstallationDetailsSuccess(_ details: AdaptyInstallationDetails) {
guard
let payloadDict = details.payload?.dictionary,
let attribution = payloadDict["attribution"] as? [String: Any]
else { return }
let channel = attribution["channel"] as? String
let campaignName = attribution["campaign_name"] as? String
let adName = attribution["ad_name"] as? String
print("Channel: \(channel ?? "organic")")
}