Impression-level revenue integration for React Native
Integrate the Impression Level Revenue (ILR) SDK API to collect detailed ad performance data and send it to your analytics tools in your React Native app.
Read time 2 minutesLast updated 3 days ago
Prerequisites
Ensure that you have correctly integrated the LevelPlay React Native plug-in 9.3.0+ into your application. For more information, refer to React Native plugin integration.
Learn more about the impression level revenue (ILR) by using the SDK feature and prerequisites.
Implement the impression data listener
The LevelPlay SDK fires postbacks to inform you about the displayed ad. is an optional listener that you can implement to receive impression data, so you can identify each ad using its impression-level revenue.
LevelPlayImpressionDataListenerStarting with plug-in version 9.3.0, you set an impression data listener on each ad object. The listener receives the impression data of that ad only.
import { type LevelPlayImpressionDataListener } from 'unity-levelplay-mediation'const impressionDataListener: LevelPlayImpressionDataListener = { onImpressionSuccess: (impressionData) => { // Use the impression data },}
Interstitial and rewarded ads
Call on the ad object before you show the ad:
setImpressionDataListenerconst interstitialAd = new LevelPlayInterstitialAd('YOUR_INTERSTITIAL_AD_UNIT_ID')interstitialAd.setImpressionDataListener(impressionDataListener)const rewardedAd = new LevelPlayRewardedAd('YOUR_REWARDED_AD_UNIT_ID')rewardedAd.setImpressionDataListener(impressionDataListener)
Banner ads
Pass the listener with the prop of :
impressionDataListenerLevelPlayBannerAdView<LevelPlayBannerAdView ref={bannerAdViewRef} adUnitId="YOUR_BANNER_AD_UNIT_ID" adSize={adSize} placementName="YOUR_PLACEMENT" listener={listener} impressionDataListener={impressionDataListener} style={{ width: adSize.width, height: adSize.height }}/>
The listener interface is:
interface LevelPlayImpressionDataListener { /** * Invoked when an impression is successfully recorded (ad is shown). * Android: onImpressionSuccess * iOS: impressionDataDidSucceed */ onImpressionSuccess: (impressionData: LevelPlayImpressionData) => void}
Integrate the ILR data
After you implement , you can use the impression data and send it to your own proprietary BI tools and DWH, or integrate it with third-party tools.
LevelPlayImpressionDataListenerYou can refer to each field on the object:
LevelPlayImpressionDataimport type { LevelPlayImpressionData } from 'unity-levelplay-mediation'// LevelPlayImpressionData type:type LevelPlayImpressionData = { auctionId: string | null; mediationAdUnitName: string | null; mediationAdUnitId: string | null; adFormat: string | null; country: string | null; ab: string | null; segmentName: string | null; placement: string | null; adNetwork: string | null; instanceName: string | null; instanceId: string | null; revenue: number | null; // Double precision: string | null; encryptedCPM: string | null; conversionValue: number | null; // Double creativeId: string | null;}
For the full list of fields and types, refer to the Impression Level Revenue SDK API documentation.