# 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:

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
val bannerAd: BannerAd

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

{% endtab %}

{% tab title="Java" %}

```java
BannerAd mBannerAd;

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

{% endtab %}
{% endtabs %}

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

<table><thead><tr><th width="139.62109375">Field</th><th width="140.36328125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>revenue</code></td><td><code>AdValue</code></td><td>The revenue generated by the ad</td></tr><tr><td><code>source</code></td><td><code>String</code></td><td>The revenue source</td></tr></tbody></table>

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

<table><thead><tr><th width="140.49609375">Field</th><th width="190.46484375">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>currency</code></td><td><code>String</code></td><td>The currency corresponding to the revenue</td></tr><tr><td><code>precision</code></td><td><code>AdValue.Precision</code></td><td>The accuracy of the information. It can be <code>ESTIMATED</code>, <code>PRECISE</code> or <code>PUBLISHER_DEFINED</code></td></tr><tr><td><code>value</code></td><td><code>Double</code></td><td>The revenue value</td></tr></tbody></table>

## Integration with Firebase

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

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
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)
}
```

{% endtab %}

{% tab title="Java" %}

```java
@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);
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wortise.com/en/android-sdk/sdk-integration/revenue-reporting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
