The Tenjin SDK can listen 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:
- Install 安装 the AppLovin Unity SDK:
<aside> 💡
Please ensure you have the latest AppLovin Unity SDK installed (>AppLovin-MAX-Unity-Plugin-5.1.2-Android-11.1.2-iOS-11.1.1)
</aside>
- Pass the revenue data to Tenjin, using the following sample code.
[System.Serializable]
public class AppLovinImpressionData
{
public string creative_id;
public string placement;
public string format;
public string country;
public string ad_revenue_currency;
public string network_placement;
public string revenue_precision;
public string ad_unit_id;
public double revenue;
public string network_name;
}
// Attach Callbacks(回传) based on the ad format(s) you are using
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
private void OnAdRevenuePaidEvent(string adUnitId, MaxSdk.AdInfo adInfo)
{
// Create impression data object for serialization
var impressionData = new AppLovinImpressionData
{
creative_id = adInfo.CreativeIdentifier ?? "",
placement = adInfo.Placement ?? "",
format = adInfo.AdFormat ?? "",
country = MaxSdk.GetSdkConfiguration().CountryCode ?? "",
ad_revenue_currency = "USD",
network_placement = adInfo.NetworkPlacement ?? "",
revenue_precision = adInfo.RevenuePrecision ?? "",
ad_unit_id = adInfo.AdUnitIdentifier ?? "",
revenue = adInfo.Revenue,
network_name = adInfo.NetworkName ?? ""
};
// Convert to JSON string using JsonUtility
string jsonString = JsonUtility.ToJson(impressionData);
// Send to Tenjin
Tenjin.getInstance("<YOUR-TENJIN-SDK_KEY>").AppLovinImpressionFromJSON(jsonString);
}
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: