Attribution

The SDK accepts attribution data from several sources: a media source descriptor, Adjust device ID, Firebase instance ID, and a referrer identifier. Providing this data before calling setup() ensures that the first configuration fetch is correctly attributed.

Media source

mediaSource carries the network, campaign, and ad group that brought the user to your app. Magify uses this information for campaign targeting and analytics segmentation.

public var mediaSource: MediaSource

MediaSource is a struct with three string fields:

public struct MediaSource: Codable, Equatable {
    public let network: String
    public let campaign: String
    public let adGroup: String

    public init(network: String? = nil, campaign: String? = nil, adGroup: String? = nil)
}

All fields default to "unknown" when not provided. Set the media source after receiving attribution data from your MMP:

magify.mediaSource = MediaSource(
    network: "facebook_ads",
    campaign: "summer_promo",
    adGroup: "us_women_25_34"
)

Assigning the same value that is already stored is a no-op; the SDK only triggers a configuration reload when the value changes.

Adjust

If your app uses the Adjust SDK, pass the Adjust device identifier so Magify can correlate events with Adjust attribution data:

public var adjustId: String?
magify.adjustId = Adjust.adid()

Setting a new value (including nil) resets the authorization token and forces a full configuration update. Setting nil when the property already held a value removes the Adjust correlation from subsequent requests. Setting the same value that is already stored is a no-op.

Firebase

If your app uses Firebase Analytics, pass the Firebase instance ID to enable cross-platform user stitching:

public var firebaseInstanceId: String?
Analytics.instanceID { id, error in
    guard let id = id else { return }
    magify.firebaseInstanceId = id
}

Setting a new value triggers a Firebase mapping event in Magify analytics. Setting nil is ignored.

Referrer

The referrer identifier links a user to a specific referral or deep-link source. Magify uses it for campaign targeting.

public var referrerId: String?
magify.referrerId = "invite_abc123"

The SDK fires a callback when this value changes:

magify.onReferrerIdChanged = {
    // React to the updated referrer.
}

Attribution and client identity

All attribution fields are associated with the SDK's clientId. To tie attribution data from a third-party MMP to the same user, set the Magify clientId as the customer user ID in that MMP before initializing it.

For integration patterns with AppsFlyer, Adjust, and other providers, refer to the Integration with other SDKs page.

Related articles

AghanimStore

AppsFlyer

IPopupWithProducts

Campaigns

Configuration

Advanced