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.
Callback Implementation
- Kotlin
- Java
Appodeal.setAdRevenueCallbacks(object : AdRevenueCallbacks {
override fun onAdRevenueReceive(revenueInfo: RevenueInfo) {
// Called whenever SDK receives revenue information for an ad
}
}
Appodeal.setAdRevenueCallbacks(new AdRevenueCallbacks() {
@Override
public void onAdRevenueReceive(@NotNull RevenueInfo revenueInfo) {
// Called whenever SDK receives revenue information for an ad
}
});
All callbacks are called on the main thread.
Appodeal Ad Revenue Description
RevenueInfo - represents revenue information from the ad network.
Parameter | Type | Description |
---|---|---|
networkName | String | The name of the ad network is guaranteed not to be null. |
demandSource | String | The demand source name and bidder name in case of impression from real-time bidding, guaranteed not to be null. |
adUnitName | String | Unique ad unit name guaranteed not to be null. |
placement | String | Appodeal's placement name is guaranteed not to be null. |
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. |
revenueCurrency | RevenueCurrency | Current currency supported by Appodeal (USD). |
currency | String | Current currency supported by Appodeal (USD) as string presentation. |
revenuePrecision | String | The revenue precision. |
The revenue precision can be:
- exact - programmatic revenue is the resulting price of the auction;
- publisher_defined - revenue from crosspromo campaigns;
- estimated - revenue based on ad network pricefloors or historical eCPM;
- undefined - 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:
- Kotlin
- Java
override fun onAdRevenueReceive(revenueInfo: RevenueInfo) {
// AppsFlyer
val customParams = mapOf(
Scheme.AD_UNIT to revenueInfo.adUnitName,
Scheme.AD_TYPE to revenueInfo.adTypeString,
)
AppsFlyerAdRevenue.logAdRevenue(
revenueInfo.networkName,
MediationNetwork.appodeal,
Currency.getInstance(Locale.US),
revenueInfo.revenue,
customParams
)
// Adjust
val adRevenue = AdjustAdRevenue(AdjustConfig.AD_REVENUE_SOURCE_PUBLISHER).apply {
setRevenue(revenueInfo.revenue, revenueInfo.currency)
setAdRevenueNetwork(revenueInfo.networkName)
setAdRevenueUnit(revenueInfo.adUnitName)
}
Adjust.trackAdRevenue(adRevenue)
// Firebase
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.AD_IMPRESSION) {
param(FirebaseAnalytics.Param.AD_PLATFORM, revenueInfo.platform)
param(FirebaseAnalytics.Param.SOURCE, revenueInfo.networkName)
param(FirebaseAnalytics.Param.AD_FORMAT, revenueInfo.adTypeString)
param(FirebaseAnalytics.Param.AD_UNIT_NAME, revenueInfo.adUnitName)
param(FirebaseAnalytics.Param.CURRENCY, revenueInfo.currency)
param(FirebaseAnalytics.Param.VALUE, revenueInfo.revenue)
}
}
@Override
public void onAdRevenueReceive(@NotNull RevenueInfo revenueInfo) {
// AppsFlyer
Map<String, String> customParams = new HashMap<>();
customParams.put(Scheme.AD_UNIT, revenueInfo.getAdUnitName());
customParams.put(Scheme.AD_TYPE, revenueInfo.getAdTypeString());
AppsFlyerAdRevenue.logAdRevenue(
revenueInfo.getNetworkName(),
MediationNetwork.appodeal,
Currency.getInstance(Locale.US),
revenueInfo.getRevenue(),
customParams
);
// Adjust
AdjustAdRevenue adRevenue = new AdjustAdRevenue(AdjustConfig.AD_REVENUE_SOURCE_PUBLISHER)
adRevenue.setRevenue(revenueInfo.getRevenue(), revenueInfo.getCurrency());
adRevenue.setAdRevenueNetwork(revenueInfo.getNetworkName());
adRevenue.setAdRevenueUnit(revenueInfo.getAdUnitName());
Adjust.trackAdRevenue(adRevenue);
// Firebase
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.AD_PLATFORM, revenueInfo.getPlatform());
bundle.putString(FirebaseAnalytics.Param.SOURCE, revenueInfo.getNetworkName());
bundle.putString(FirebaseAnalytics.Param.AD_FORMAT, revenueInfo.getAdTypeString());
bundle.putString(FirebaseAnalytics.Param.AD_UNIT_NAME, revenueInfo.getAdUnitName());
bundle.putString(FirebaseAnalytics.Param.CURRENCY, RevenueInfo.getCurrency());
bundle.putString(FirebaseAnalytics.Param.VALUE, RevenueInfo.getRevenue());
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.AD_IMPRESSION, bundle);
}