Tenjin SDK có thể truy xuất dữ liệu doanh thu ở cấp độ hiển thị quảng cáo từ AppLovin và gửi các sự kiện doanh thu đến Tenjin. Tích hợp này sẽ gửi các thông tin liên quan đến doanh thu cho mỗi lần hiển thị quảng cáo được phân phối từ AppLovin. Dưới đây là các bước để thực hiện tích hợp:
- Cài đặt SDK AppLovin iOS: https://developers.axon.ai/en/max/ios/overview/integration
Vui lòng đảm bảo rằng bạn đã cài đặt phiên bản mới nhất của SDK AppLovin iOS (> 11.0.0) - Hãy chuyển dữ liệu doanh thu sang Tenjin bằng cách sử dụng đoạn mã mẫu sau đây.
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)")
}
}Dưới đây là một ví dụ về việc nhập dữ liệu doanh thu theo mức hiển thị từ AppLovin. Đối với tham số doanh thu, hãy sử dụng kiểu double, không phải kiểu string.
| Tham số | Có bắt buộc không? | Ví dụ |
|---|---|---|
| creative_id | Không | 2813803997 |
| vị trí | Không | banner quảng cáo |
| định dạng | Không | BANNER |
| quốc gia | Không | DE |
| đơn vị tiền tệ doanh thu quảng cáo | Không | USD |
| vị trí_mạng | Không | banner_thông thường |
| độ chính xác doanh thu | Không | chính xác |
| ad_unit_id | Không | a7d1aa174c93c716 |
| doanh thu | Có | 4.7455200000000006E-5 |
| tên_mạng | Có | APPLOVIN_EXCHANGE |
Nguồn tham khảo: https://developers.axon.ai/en/max/ios/overview/advanced-settings/#impression-level-user-revenue-API