The Tenjin SDK can fetch to AppLovin impression level revenue data and send revenue events to Tenjin. This integration will send revenue related for each ad impression served from AppLovin. Here are the steps to integrate:
- Установите the AppLovin iOS SDK: https://developers.axon.ai/en/max/ios/overview/integration
<aside> 💡
Please ensure you have the latest AppLovin iOS SDK installed (> 11.0.0)
</aside>
- Pass the revenue data to Tenjin, using the following sample code.
Objective-C #
- (void)didPayRevenueForAd:(MAAd *)ad {
double revenue = ad.revenue; // In USD
// Create JSON object for Tenjin
NSDictionary *impressionData = @{
@"creative_id" : ad.creativeIdentifier ?: @"",
@"placement" : ad.placement ?: @"",
@"format" : ad.format.displayName ?: @"",
@"country" : [ALSdk shared].configuration.countryCode ?: @"",
@"ad_revenue_currency" : @"USD",
@"network_placement" : ad.networkPlacement ?: @"",
@"revenue_precision" : ad.revenuePrecision ?: @"",
@"ad_unit_id" : ad.adUnitIdentifier ?: @"",
@"revenue" : @(revenue),
@"network_name" : ad.networkName ?: @""
};
// Convert to JSON string
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:impressionData
options:0
error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
// Send to Tenjin
[TenjinSDK appLovinImpressionFromJSON:jsonString];
NSLog(@"Sent impression to Tenjin: %@", jsonString);
}
Swift #
func didPayRevenue(_ ad: MAAd) {
let revenue = ad.revenue // In USD
// Create JSON object for Tenjin
let impressionData: [String: Any] = [
"creative_id": ad.creativeIdentifier ?? "",
"placement": ad.placement ?? "",
"format": ad.format.displayName ?? "",
"country": ALSdk.shared().configuration.countryCode ?? "",
"ad_revenue_currency": "USD",
"network_placement": ad.networkPlacement ?? "",
"revenue_precision": ad.revenuePrecision ?? "",
"ad_unit_id": ad.adUnitIdentifier ?? "",
"revenue": revenue,
"network_name": ad.networkName ?? ""
]
// Convert to JSON string
do {
let jsonData = try JSONSerialization.data(withJSONObject: impressionData, options: [])
if let jsonString = String(data: jsonData, encoding: .utf8) {
// Send to Tenjin
TenjinSDK.appLovinImpressionFromJSON(jsonString)
print("Sent impression to Tenjin: \\(jsonString)")
}
} catch {
print("Error creating JSON: \\(error)")
}
}
Here is an example impression level revenue data entry from AppLovin. For a revenue parameter, use double type, not string type.
| Parameter | Required? | Example |
|---|---|---|
| creative_id | Нет | 2813803997 |
| placement | Нет | placementBanner |
| format | Нет | BANNER |
| country | Нет | DE |
| ad_revenue_currency | Нет | USD |
| network_placement | Нет | banner_regular |
| revenue_precision | Нет | exact |
| ad_unit_id | Нет | a7d1aa174c93c716 |
| выручка | Да | 4.7455200000000006E-5 |
| network_name | Да | APPLOVIN_EXCHANGE |
reference: