文档

支持

LevelPlay SDK - iOS

Impression-level revenue integration for iOS

Integrate impression-level revenue data into your analytics platform by using the Impression Level Revenue (ILR) SDK API.
阅读时间2 分钟最后更新于 4 天前

Prerequisites

Ensure that you have correctly integrated the LevelPlay SDK 7.0.3+ into your application. Refer to iOS SDK integration. For more information about the Impression Level Revenue (ILR) SDK feature and pre-requisites, refer to Impression-level revenue server-side API.

Implement the ImpressionData Listener

The LevelPlay SDK fires postbacks to inform you about the displayed ad. The ImpressionData listener 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 ImpressionData listener to your application, declare the listener before initializing the LevelPlay SDK to avoid any loss of information.
+ (void)addImpressionDataDelegate:(id<LPMImpressionDataDelegate>)delegate;
The LevelPlay SDK will notify your listener of the success post-backs related to impression data:
- (void)impressionDataDidSucceed:(LPMImpressionData *)impressionData;

Remove Impression Data Listener

To remove the ImpressionData listener from your application, use the removeImpressionData API:
+ (void)removeImpressionDataDelegate:(id<LPMImpressionDataDelegate>)delegate;
注意
As of LevelPlay SDK 7.1.0 release, setImpressionDataDelegate is deprecated and replaced with addImpressionDataDelegate.

Integrate the ILR data

After you implement the ImpressionDataListener, you can send the impression data to your own proprietary BI tools and DWH or integrate it with third-party tools.
重要
The returned data might include null values. Ensure that you add protections before assigning the data to avoid potential crashes.
You can refer to each field separately or get all information by using the allData method:
- (void)impressionDataDidSucceed:(LPMImpressionData *)impressionData { NSNumber *revenue = impressionData.revenue; NSString *ad_network = impressionData.adNetwork; NSDictionary *all_data = impressionData.allData;}
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.
重要
Ensure that the inside parameters aren’t null.
/** Invoked when the ad was displayed successfully and the impression data was recorded **/- (void)impressionDataDidSucceed:(LPMImpressionData *)impressionData { NSLog(@"%s", __PRETTY_FUNCTION__); [FIRAnalytics logEventWithName:kFIREventAdImpression parameters:@{ kFIRParameterAdPlatform:@"LevelPlay", kFIRParameterAdSource:(impressionData.ad_network ?: @"No ad_network"), kFIRParameterAdFormat:(impressionData.ad_format ?: @"No ad_format"), kFIRParameterAdUnitName:(impressionData.instance_name ?: @"No instance_name"), kFIRParameterCurrency:@"USD", kFIRParameterValue:(impressionData.revenue ?: @0) }];}