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:
- Установите the AdMob iOS SDK: https://developers.google.com/admob/ios/quick-start
<aside> 💡
Please ensure you have the latest Google-Mobile-Ads-SDK iOS SDK installed (> 8.10.0)
</aside>
- Turn on the setting for impression-level ad revenue in your AdMob account:
- Sign in to your AdMob account at https://admob.google.com.
- Click Settings in the sidebar.
- Click the Account tab.
- In the Account controls section, next to “Impression-level ad revenue” click to edit.
- Click the toggle to turn on this setting.
- Click Save.
- Integrate AdMob SDK in your app by following the sample code below.
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 |