Impression-level revenue integration for Android
Integrate the Impression Level Revenue (ILR) SDK API to capture real-time ad revenue data for each impression, enabling detailed monetization insights and seamless integration with third-party analytics platforms.
阅读时间2 分钟最后更新于 4 天前
Prerequisites
Ensure that you have correctly integrated the LevelPlay SDK 7.0.3+ into your application. Refer to Integration checklists for Android.Implement the LevelPlayImpressionDataListener
The LevelPlay SDK fires postbacks to inform you about the displayed ad. The LevelPlayImpressionDataListener is an optional listener that you can implement to receive impression data. This listener will provide you with information about all ad units, and you'll be able to identify the different ads by using the impression level revenue. To add the LevelPlayImpressionDataListener to your application, declare the listener before initializing the LevelPlay SDK to avoid any loss of information.The LevelPlay SDK will notify your listener of the success post-backs related to impression data:public static void addImpressionDataListener(LevelPlayImpressionDataListener listener)
public static void addImpressionDataListener(ImpressionDataListener listener){ /** Invoked when the ad was displayed successfully and the impression data was recorded **/ }
Remove Impression Data Listener
To remove the LevelPlayImpressionDataListener from your application, use the removeImpressionDataListener API:public static void removeImpressionDataListener(LevelPlayImpressionDataListener listener);
Integrate the ILR data
After you implement the LevelPlayImpressionDataListener, you can send the impression data to your own proprietary BI tools and DWH or integrate it with third-party tools.
You can refer to each field separately or get all information by using the allData method:
For the full list of available ILR data, including field description and types, refer to Impression Level Revenue SDK API. The following example shows how to integrate the Impression Level Revenue SDK API data with Google Analytics for Firebase. You can use it as-is or make any required changes to integrate with third-party reporting tools or your own proprietary optimization tools and databases.public void onImpressionSuccess (LevelPlayImpressionData impressionData){ Double revenue = impressionData.getRevenue(); String adNetwork = impressionData.getAdNetwork(); JSONObject allData = impressionData.getAllData(); }
/** Invoked when the ad was displayed successfully and the impression data was recorded **/ @Override public void onImpressionSuccess(LevelPlayImpressionData impressionData) { // The onImpressionSuccess will be reported when the rewarded video and interstitial ad is opened. // For banners, the impression is reported on load success. Log.d(TAG, "onImpressionSuccess" + impressionData); if (impressionData != null) { Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.AD_PLATFORM, "LevelPlay"); bundle.putString(FirebaseAnalytics.Param.AD_SOURCE, impressionData.getAdNetwork()); bundle.putString(FirebaseAnalytics.Param.AD_FORMAT, impressionData.getAdFormat()); bundle.putString(FirebaseAnalytics.Param.AD_UNIT_NAME, impressionData.getInstanceName()); bundle.putString(FirebaseAnalytics.Param.CURRENCY, "USD"); bundle.putDouble(FirebaseAnalytics.Param.VALUE, java.util.Objects.requireNonNullElse(impressionData.getRevenue(), 0.0)); // Add protection for null values mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.AD_IMPRESSION, bundle); } }