Skip to content

Revenue reporting

Since version 1.7.0, apps can receive an estimated revenue that has likely been generated by an ad.

To do this, it is just needed to implement the corresponding listener for each ad format, as shown in the example below:

val bannerAd: BannerAd
bannerAd.listener = object : BannerAd.Listener() {
override fun onBannerRevenuePaid(ad: BannerAd, data: Revenuedata) {
// Invoked when the ad has generated revenue
}
}

The listener receives an object of type RevenueData that contains the following fields:

FieldTypeDescription
revenueAdValueThe revenue generated by the ad
sourceStringThe revenue source

In addition, the AdValue class contains the following fields that represent the revenue:

FieldTypeDescription
currencyStringThe currency corresponding to the revenue
precisionAdValue.PrecisionThe accuracy of the information. It can be ESTIMATED, PRECISE or PUBLISHER_DEFINED
valueDoubleThe revenue value

Below, a basic example is shown of how to report the revenue information to Firebase:

override func onBannerRevenuePaid(ad: BannerAd, data: RevenueData) {
val bundle = Bundle().apply {
putString("currency", data.revenue.currency)
putString("precision", data.revenue.precision?.name)
putString("source", data.source)
putDouble("value", data.revenue.value)
}
Firebase.analytics.logEvent("ad_revenue", bundle)
}