The Tenjin SDK can listen to AdMob impression level revenue data and send revenue events to Tenjin. This integration will send revenue related for each ad impression served from AdMob. Here are the steps to integrate:
- Install the AdMob iOS SDK: https://developers.google.com/admob/ios/quick-start
Please ensure you have the latest Google-Mobile-Ads-SDK iOS SDK installed (> 8.10.0) - Turn on the setting for impression-level ad revenue in your AdMob account:
- Sign in to your AdMob account at https://admob.google.com.
- クリック Settings in the sidebar.
- + Link IDボタンをクリックし、ドロップダウンから Account タブをクリックします。
- In the Account controls section, next to “Impression-level ad revenue” click to edit.
- Click the toggle to turn on this setting.
- クリック Saveをクリックします。.
- Integrate AdMob SDK in your app by following the sample code below.
Objective-C
self.rewardedAd.paidEventHandler = ^void(GADAdValue *_Nonnull value) {
ViewController *strongSelf = weakSelf;
// Extract the impression-level ad revenue data
NSDecimalNumber *adValue = value.value;
NSString *currencyCode = value.currencyCode;
NSInteger precision = value.precision;
// Get the ad unit ID and response info
NSString *adUnitId = strongSelf.rewardedAd.adUnitID;
GADResponseInfo *responseInfo = strongSelf.rewardedAd.responseInfo;
NSString *responseIdentifier = responseInfo.responseIdentifier;
NSString *adNetworkClassName = responseInfo.loadedAdNetworkResponseInfo.adNetworkClassName;
NSDictionary *jsonDict = @{
@"ad_unit_id": adUnitId,
@"value_micros": adValue,
@"currency_code": currencyCode,
@"response_id": responseIdentifier,
@"mediation_adapter_class_name": adNetworkClassName,
@"precision_type": @(precision)
};
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:0 error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[TenjinSDK adMobImpressionFromJSON:jsonString];
}];
Here is an example impression level revenue data entry from AdMob.
| Parameter | Required? | Example |
|---|---|---|
| ad_unit_id | いいえ | ca-app-pub-3940256099942544%2F2934735716 |
| currency_code | いいえ | USD |
| response_id | いいえ | CKak5t_oovcCFRPJdwodJXQNRw |
| value_micros | はい | 0.0001 |
| mediation_adapter_class_name | いいえ | GADMAdapterGoogleAdMobAds |
| precision_type | いいえ | Unknown |