SDK Documentation
HomeBlogSign up
English
English
  • 🏠Homepage
  • 🧪Test Ad Units
  • Privacy
    • ✅Google Data Safety
  • Android SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
    • 🛠️ProGuard
  • iOS SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Revenue reporting
    • 🙍User consent
    • 🔓Privacy
  • Unity SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • Flutter SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • React Native
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • Web SDK
    • ⌨️SDK integration
Con tecnología de GitBook
En esta página
  • Implementation
  • Integration with Firebase
  1. Android SDK
  2. SDK integration

Revenue reporting

Implementation

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
    }
}
BannerAd mBannerAd;

mBannerAd.setListener(new BannerAd.Listener() {
    @Override
    public void onBannerRevenuePaid(@NonNull BannerAd ad,
                                    @NonNull Revenuedata data) {
        // Invoked when the ad has generated revenue
    }
});

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

Field
Type
Description

revenue

AdValue

The revenue generated by the ad

source

String

The revenue source

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

Field
Type
Description

currency

String

The currency corresponding to the revenue

precision

AdValue.Precision

The accuracy of the information. It can be ESTIMATED, PRECISE or PUBLISHER_DEFINED

value

Double

The revenue value

Integration with Firebase

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)
}
@Override
public void onBannerRevenuePaid(@NonNull BannerAd ad,
                                @NonNull RevenueData data) {
    Bundle bundle = new Bundle();

    bundle.putString("source", data.getSource());
    
    AdValue revenue = data.getRevenue();

    bundle.putString("currency",  revenue.getCurrency());
    bundle.putDouble("value",     revenue.getValue());
    
    AdValue.Precision precision = revenue.getPrecision();
    
    if (precision != null) {
        bundle.putString("precision", precision.name());
    }

    FirebaseAnalytics.getInstance(context).logEvent("ad_revenue", bundle);
}
AnteriorTargetingSiguienteUser consent

Última actualización hace 3 días

⌨️