Advertisement
The SDK provides APIs for forwarding ad impression and click events from your ad mediator to Magify. This data feeds into analytics and campaign attribution — it is not collected automatically on native iOS. You must forward each impression from the mediator's callback.
Ad campaign types
Use the CampaignType values that represent ad placements when calling impression tracking methods. Only the following types are valid for trackAdsImpression:
Passing any other CampaignType to trackAdsImpression is a no-op and logs a warning.
Track an ad impression
Call trackAdsImpression(for:impressionData:) in the mediator's impression callback, after the ad is shown.
magify.trackAdsImpression(for: campaignType, impressionData: impressionData)
The impressionData parameter must be one of AppLovinImpressionData or IronSourceImpressionData.
AppLovin MAX
import Magify
// Inside your MARewardedAdDelegate / MAAdRevenueDelegate callback:
func didPayRevenue(for ad: MAAd) {
let impressionData = AppLovinImpressionData(
adUnitId: ad.adUnitIdentifier,
networkName: ad.networkName,
impressionId: ad.impressionIdentifier,
revenuePrecision: ad.revenuePrecision,
revenue: ad.revenue
)
magify.trackAdsImpression(for: .rewardedVideo, impressionData: impressionData)
}
Map the AppLovin MAX ad format to the corresponding CampaignType:
MAAdFormat.banner/.mrec/.leader→.bannerMAAdFormat.interstitial→.interstitialMAAdFormat.rewarded→.rewardedVideo
LevelPlay (IronSource)
import Magify
// Inside your LevelPlayRewardedAdDelegate / impression callback:
func didReceiveImpression(for ad: LevelPlayAdInfo) {
let impressionData = IronSourceImpressionData(
adUnitId: ad.adUnitId,
networkName: ad.networkName ?? "",
instanceName: ad.instanceName,
instanceId: ad.instanceId,
revenue: ad.revenue,
revenuePrecision: ad.revenuePrecision,
ab: ad.ab,
auctionId: ad.auctionId,
segmentName: ad.segmentName,
lifetimeRevenue: ad.lifetimeRevenue,
encryptedCPM: ad.encryptedCPM
)
magify.trackAdsImpression(for: .rewardedVideo, impressionData: impressionData)
}
Track an ad click
Call trackAdsClick(for:) when the user taps the ad.
magify.trackAdsClick(for: .interstitial)
Pass the same CampaignType used when the impression was tracked.
Track a product click inside an ad
If the ad contains a purchasable product button (e.g. a rewarded offer), call trackAdsPurchaseClick(for:productId:) when the user taps the product.
magify.trackAdsPurchaseClick(for: .rewardedVideo, productId: "com.example.coins_pack")
Impression data types
AppLovinImpressionData
public struct AppLovinImpressionData: ImpressionDataType {
public let adUnitId: String
public let networkName: String
public let impressionId: String?
public let revenuePrecision: String?
public let revenue: Double?
}
IronSourceImpressionData
public struct IronSourceImpressionData: ImpressionDataType {
public let adUnitId: String
public let networkName: String
public let instanceName: String?
public let instanceId: String
public let revenue: Double?
public let revenuePrecision: String?
public let ab: String?
public let auctionId: String?
public let segmentName: String?
public let lifetimeRevenue: Double?
public let encryptedCPM: String?
}
Both types conform to ImpressionDataType. Pass nil for any optional field your mediator does not provide.
Next step
For purchase tracking triggered after an ad interaction, see the Purchases section.