Ad Revenue Callbacks
Appodeal SDK allows you to get impression-level revenue data with Ad Revenue Callbacks. This data includes information about network name, revenue, ad type, etc.
The impression-level ad revenue data can be used then to share with your mobile measurement partner of choice, such as Firebase, for all supported networks.
If you have integrated Firebase, which is included in Appodeal SDK, using this guide, then ad revenue data will be sent automatically, you can read more about it here in Step 2.
Appodeal SDK 3.0.1+
Callback Implementation
- Swift
- Objective-C
extension YourViewController: UIViewController, AppodealAdRevenueDelegate {
override func viewDidLoad() {
super.viewDidLoad()
Appodeal.setAdRevenueDelegate(self)
}
func didReceiveRevenue(forAd ad: AppodealAdRevenue) {
let parameters: [String: Any] = [
"network": ad.networkName,
"ad_unit": ad.adUnitName,
"placement": ad.placement,
"revenue_precision": ad.revenuePrecision,
"demand": ad.demandSource,
"currency": ad.currency,
"revenue": ad.revenue,
"ad_type": ad.adTypeString
]
}
}
@interface YourViewController () <AppodealAdRevenueDelegate>
@end
@implementation YourViewController
- (void)viewDidLoad {
[super viewDidLoad];
[Appodeal setAdRevenueDelegate:self];
}
- (void)didReceiveRevenueForAd:(id<AppodealAdRevenue>)ad {
NSDictionary<NSString *, id> *parameters = @{
@"network": ad.networkName,
@"ad_unit": ad.adUnitName,
@"placement": ad.placement,
@"revenue_precision": ad.revenuePrecision,
@"demand": ad.demandSource,
@"currency": ad.currency,
@"revenue": @(ad.revenue),
@"ad_type": ad.adTypeString
};
}
@end
To get impression-level ad revenue from Admob you also need to turn on the setting in your AdMob account.
Go to your Admob Account Settings → Account → turn on Impression-level ad revenue toggle.
Appodeal Ad Revenue Description
AppodealAdRevenue
- represents revenue information from the ad network.
Parameter | Type | Description |
---|---|---|
networkName | String | The name of the ad network. |
demandSource | String | The demand source name and bidder name in case of impression from real-time bidding |
adUnitName | String | Unique ad unit name. |
placement | String | Appodeal's placement name. |
revenue | Double | The ad's revenue amount or 0 if it doesn't exist. |
adType | Int | Appodeal's ad type. |
adTypeString | String | Appodeal's ad type as string presentation. |
platform | String | Appodeal's platform name. |
currency | String | Current currency supported by Appodeal (USD) as string presentation. |
revenuePrecision | String | The revenue precision. |
exact
- programmatic revenue is the resulting price of the auctionpublisher_defined
- revenue from crosspromo campaignsestimated
- revenue based on ad network pricefloors or historical eCPMundefined
- revenue amount is not defined
Use Case
If you have integrated analytics for example Firebase using this guide with Appodeal, then no additional steps are required.
In case you are using your own analytics in the project, please find the example below:
- Swift
- Objective-C
extension YourViewController: UIViewController, AppodealAdRevenueDelegate {
override func viewDidLoad() {
super.viewDidLoad()
Appodeal.setAdRevenueDelegate(self)
}
func didReceiveRevenue(forAd ad: AppodealAdRevenue) {
let parameters: [String: Any] = [
"network": ad.networkName,
"ad_unit": ad.adUnitName,
"placement": ad.placement,
"revenue_precision": ad.revenuePrecision,
"demand": ad.demandSource,
"currency": ad.currency,
"revenue": ad.revenue,
"ad_type": ad.adTypeString
]
//AppsFlyer
let adRevenueParams:[AnyHashable: Any] = [
kAppsFlyerAdRevenueAdUnit : ad.adUnitName,
kAppsFlyerAdRevenueAdType : ad.adTypeString
]
AppsFlyerAdRevenue.shared().logAdRevenue(
monetizationNetwork: ad.networkName,
mediationNetwork: MediationNetworkType.appodeal,
eventRevenue: ad.revenue,
revenueCurrency: ad.currency,
additionalParameters: adRevenueParams
)
//Adjust
let adRevenue = ADJAdRevenue(source: ADJAdRevenueSourcePublisher)
adRevenue.setRevenue(ad.revenue, currency: ad.currency)
adRevenue.adRevenueUnit(ad.adUnitName)
adRevenue.adRevenueNetwork(ad.networkName)
Adjust.trackAdRevenue(adRevenue)
//Firebase
Analytics.logEvent(AnalyticsEventAdImpression, parameters: [
AnalyticsParameterAdFormat: ad.adTypeString,
AnalyticsParameterAdSource: ad.networkName,
AnalyticsParameterAdUnitName: ad.adUnitName,
AnalyticsParameterAdCurrency: ad.currency,
AnalyticsParameterValue: ad.revenue
])
}
}
@interface YourViewController () <AppodealAdRevenueDelegate>
@end
@implementation YourViewController
- (void)viewDidLoad {
[super viewDidLoad];
[Appodeal setAdRevenueDelegate:self];
}
- (void)didReceiveRevenueForAd:(id<AppodealAdRevenue>)ad {
NSDictionary<NSString *, id> *parameters = @{
@"network": ad.networkName,
@"ad_unit": ad.adUnitName,
@"placement": ad.placement,
@"revenue_precision": ad.revenuePrecision,
@"demand": ad.demandSource,
@"currency": ad.currency,
@"revenue": @(ad.revenue),
@"ad_type": ad.adTypeString
};
//AppsFlyer
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
dictionary[kAppsFlyerAdRevenueAdUnit] = ad.adUnitName
dictionary[kAppsFlyerAdRevenueAdType] = ad.adTypeString
[[AppsFlyerAdRevenue shared] logAdRevenueWithMonetizationNetwork:ad.networkName
mediationNetwork:AppsFlyerAdRevenueMediationNetworkTypeAppodeal
eventRevenue:ad.revenue
revenueCurrency:ad.currency
additionalParameters:dictionary];
//Adjust
ADJAdRevenue *adRevenue = [ADJAdRevenue alloc initWithSource: ADJAdRevenueSourcePublisher];
[adRevenue setRevenue:ad.revenue currency:ad.currency];
[adRevenue setAdRevenueUnit:ad.adUnitName];
[adRevenue setAdRevenueNetwork:ad.networkName];
[Adjust trackAdRevenue:adRevenue];
//Firebase
[FIRAnalytics logEventWithName:kFIREventAdImpression
parameters:@{
kFIRParameterAdFormat:ad.adTypeString,
kFIRParameterAdSource:ad.networkName,
kFIRParameterAdUnitName:ad.adUnitName,
kFIRParameterCurrency:ad.currency,
kFIRParameterValue:ad.revenue,
}];
}
@end