请参阅 AppLovin MAX 文档 安装 AppLovin MAX SDK。
提示
此功能处于测试阶段。 如有疑问或功能需求,请联系您的 CSM。
请在 AppLovin MAX SDK 的 OnAdRevenuePaidEvent
回调中获取广告收入数据并将其传递至 Airbridge SDK,如下所示:
private void OnEnable() {
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.RewardedInterstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
}
private void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
if (adInfo != null) {
AirbridgeEvent @event = new AirbridgeEvent("airbridge.adImpression");
var appLovin = new Dictionary<string, object>();
appLovin["revenue"] = adInfo.Revenue;
appLovin["country_code"] = MaxSdk.GetSdkConfiguration().CountryCode;
appLovin["network_name"] = adInfo.NetworkName;
appLovin["network_placement"] = adInfo.NetworkPlacement;
appLovin["adunit_identifier"] = adInfo.AdUnitIdentifier;
appLovin["creative_identifier"] = adInfo.CreativeIdentifier;
appLovin["placement"] = adInfo.Placement;
var adPartners = new Dictionary<string, object>();
adPartners["appLovin"] = appLovin;
@event.SetAction(adInfo.NetworkName);
@event.SetLabel(adInfo.NetworkPlacement);
@event.SetValue(adInfo.Revenue);
@event.AddSemanticAttribute("adPartners", adPartners);
// AppLovin MAX has a default currency of USD
@event.AddSemanticAttribute("currency", "USD");
AirbridgeUnity.TrackEvent(@event);
}
}
function App(): JSX.Element {
useEffect(() => {
// Helper function to add an ad revenue paid listener
const addAdRevenuePaidListener = (AdClass) => {
AdClass.addAdRevenuePaidListener(adInfo => {
if (adInfo) {
onAdRevenuePaidEvent(adInfo);
}
});
};
// Set up event listeners
[BannerAd, InterstitialAd, RewardedAd, AppOpenAd, MRecAd].forEach(addAdRevenuePaidListener);
}, []);
const onAdRevenuePaidEvent = (adInfo: AdRevenueInfo) => {
const airbridgeSemanticAttributes = {
adPartners: {
appLovin: {
revenue: adInfo.revenue,
country_code: adInfo.countryCode,
network_name: adInfo.networkName,
network_placement: adInfo.networkPlacement,
adunit_identifier: adInfo.adUnitId,
creative_identifier: adInfo.creativeId,
placement: adInfo.placement,
},
},
currency: 'USD', // Assuming USD as default
}
Airbridge.trackEvent('airbridge.adImpression', {
action: adInfo.networkName,
label: adInfo.networkPlacement,
value: adInfo.revenue,
semanticAttributes: airbridgeSemanticAttributes
});
};
return (
/* Your JSX goes here */
);
}
public class InterstitialAdActivity
extends BaseAdActivity
implements MaxAdListener, MaxAdRevenueListener
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
...
// Set up event listener
interstitialAd.setRevenueListener(this);
...
}
@Override
public void onAdRevenuePaid(final MaxAd maxAd)
{
Event event = new Event("airbridge.adImpression");
Map<String, Object> appLovin = new HashMap<>();
appLovin.put("revenue", maxAd.getRevenue());
appLovin.put("country_code", AppLovinSdk.getInstance(this).getConfiguration().getCountryCode());
appLovin.put("network_name", maxAd.getNetworkName());
appLovin.put("network_placement", maxAd.getNetworkPlacement());
appLovin.put("adunit_identifier", maxAd.getAdUnitId());
appLovin.put("creative_identifier", maxAd.getCreativeId());
appLovin.put("placement", maxAd.getPlacement());
Map<String, Object> adPartners = new HashMap<>();
adPartners.put("appLovin", appLovin);
Map<String, Object> semanticAttributes = new HashMap<>();
semanticAttributes.put("adPartners", adPartners);
// AppLovin MAX has a default currency of USD
semanticAttributes.put("currency", "USD");
event.setAction(maxAd.getNetworkName());
event.setLabel(maxAd.getNetworkPlacement());
event.setValue(maxAd.getRevenue());
event.setSemanticAttributes(semanticAttributes);
Airbridge.trackEvent(event);
}
}
class InterstitialAdActivity : BaseAdActivity(),
MaxAdListener, MaxAdRevenueListener {
override fun onCreate(savedInstanceState: Bundle?) {
...
// Set up event listener
interstitialAd.setRevenueListener(this)
...
}
override fun onAdRevenuePaid(ad: MaxAd) {
val event = Event("airbridge.adImpression")
val appLovin = mutableMapOf<String, Any?>()
appLovin["revenue"] = ad.revenue
appLovin["country_code"] = AppLovinSdk.getInstance(this).configuration.countryCode
appLovin["network_name"] = ad.networkName
appLovin["network_placement"] = ad.networkPlacement
appLovin["adunit_identifier"] = ad.adUnitId
appLovin["creative_identifier"] = ad.creativeId
appLovin["placement"] = ad.placement
val adPartners = mapOf("appLovin" to appLovin)
event.action = ad.networkName
event.label = ad.networkPlacement
event.value = ad.revenue
event.semanticAttributes = mutableMapOf(
"adPartners" to adPartners,
// AppLovin MAX has a default currency of USD
"currency" to "USD"
)
Airbridge.trackEvent(event)
}
}
Was this page helpful?