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 分最終更新 1ヶ月前
Prerequisites
Ensure that you have correctly integrated the LevelPlay SDK 9.5.0+ 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 LPMImpressionDataDelegate
The LevelPlay SDK fires postbacks to inform you about the displayed ad. The LPMImpressionDataDelegate is an optional delegate 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 delegate of the success post-backs related to impression data:
- (void)impressionDataDidSucceed:(LPMImpressionData *)impressionData;
Set up the Impression Delegate
Implement and set it on each ad object by calling . Assign it right after constructing the ad object and before loading or showing it, so the impression is not missed. Each delegate receives impressions only for the instance it is assigned to.
LPMImpressionDataDelegatesetImpressionDataDelegate:Interstitial
self.interstitialAd = [[LPMInterstitialAd alloc] initWithAdUnitId:@"adUnitId"];[self.interstitialAd setImpressionDataDelegate:self];#pragma mark - LPMImpressionDataDelegate Methods- (void)impressionDataDidSucceed:(LPMImpressionData *)impressionData { NSLog(@"Interstitial impressionDataDidSucceed: %@", impressionData);}
Rewarded
self.rewardedAd = [[LPMRewardedAd alloc] initWithAdUnitId:@"adUnitId"];[self.rewardedAd setImpressionDataDelegate:self];#pragma mark - LPMImpressionDataDelegate Methods- (void)impressionDataDidSucceed:(LPMImpressionData *)impressionData { NSLog(@"Rewarded impressionDataDidSucceed: %@", impressionData);}
Banner
self.bannerAdView = [[LPMBannerAdView alloc] initWithAdUnitId:@"adUnitId"];[self.bannerAdView setImpressionDataDelegate:self];#pragma mark - LPMImpressionDataDelegate Methods- (void)impressionDataDidSucceed:(LPMImpressionData *)impressionData { NSLog(@"Banner impressionDataDidSucceed: %@", impressionData);}
Remove Impression Data Listener
To stop receiving impression data for an ad object, pass to .
nilsetImpressionDataDelegate:[self.interstitialAd setImpressionDataDelegate:nil];[self.rewardedAd setImpressionDataDelegate:nil];[self.bannerAdView setImpressionDataDelegate:nil];
Integrate the ILR data
After you implement the LPMImpressionDataDelegate, 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:
- (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.
/** 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) }];}