기술 자료

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분최근 업데이트: 하루 전

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
LPMImpressionDataDelegate
and set it on each ad object by calling
setImpressionDataDelegate:
. 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.
참고
The ad object holds the impression delegate weakly. Keep a strong reference to your delegate, otherwise it may be deallocated and stop receiving callbacks.

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);}
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
nil
to
setImpressionDataDelegate:
.
[self.interstitialAd setImpressionDataDelegate:nil];[self.rewardedAd setImpressionDataDelegate:nil];[self.bannerAdView setImpressionDataDelegate:nil];
참고
As of LevelPlay SDK 7.1.0 release, setImpressionDataDelegate is deprecated and replaced with addImpressionDataDelegate.

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.
중요
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) }];}