When an impression occurs, Google Mobile Ads SDK for React Native provides ad revenue data associated with that impression. Use this data to calculate a user's lifetime value (LTV), or forward the data to analytics platforms or third-party attribution partners.
This guide covers implementing impression-level ad revenue data capture in your React Native app.
Prerequisites
Before you continue, do the following:
Turn on impression-level ad revenue in the AdMob UI. For details, see Use impression-level ad revenue in the AdMob UI.
Implement at least one ad format:
Register a paid event handler
Each ad format supports an onAdPaid event
callback. During an ad lifecycle, Google Mobile Ads SDK for React Native monitors impression
events and invokes the handler with an earned AdValue
payload.
The following example registers a paid event listener on a rewarded ad, logs the earned ad revenue data, and shows the ad:
const rewarded = await RewardedAd.load(adRequest);
rewarded.adEventCallback = {
onAdPaid(adValue: AdValue) {
const revenue = adValue.amountMicros / 1000000;
console.log(`Earned ad revenue: ${revenue} ${adValue.currencyCode}`);
console.log(`Precision level: ${adValue.precision}`);
},
};
rewarded.show();
We recommend you do the following:
For full-screen ads, set the listener on the ad object after you load the ad and before showing the ad. For banner and native ads, pass the
onAdPaidcallback as a prop to the<BannerAdView />or<NativeAdView />component. This process makes sure that you don't miss any paid event callbacks.Send the impression-level ad revenue information to your preferred analytics server when Google Mobile Ads SDK for React Native calls the
onAdPaidcallback. This process makes sure that you don't miss callbacks and keeps your data consistent.
Learn about AAP integration
For details on forwarding ad revenue data to analytics platforms, see the following App Attribution Partners (AAP) guides:
Understand the AdValue object
An AdValue object represents the monetary value earned for an ad,
including the currency code and precision type. The following table lists the
AdValue object properties:
| Property | Description |
|---|---|
amountMicros |
The ad revenue in micro-units, where 1000000 micros equals one unit of currency, such as US$1.00 or €1.00. |
currencyCode |
The ISO 4217 currency code of the ad value, for example, USD or EUR. |
precision |
The precision level of the ad value. The following list details each precision level:
|
In AdMob Mediation, AdMob attempts to provide an ESTIMATED
value for ad sources that
are optimized. For details, see
Optimize waterfall ad sources in mediation.
If an ad source isn't optimized, or lacks enough aggregated
data for an estimate, Google Mobile Ads SDK for React Native returns the PUBLISHER_PROVIDED precision
type.
Test impressions from bidding ad sources
After an impression-level ad revenue event occurs for a bidding ad source through a test request, you receive only the following values:
UNKNOWN: indicates the precision type.
0: indicates the ad value.
For details on sending a test ad request, see Enable test devices.