💡Tips
- 🟢 本文示例以插屏广告样式演示,其他广告样式实现逻辑相同
- 🔵 回传参数仅供参考,请根据实际业务需要自行选择参数上报回传
- ⚠️ 使用Firebase与AdMob关联集成时,需避免AdMob收益重复上报
- 如下示例code仅供参考,详情请参考Firebase官方文档
private void OnInterstitialRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// 使用Firebase与AdMob关联,避免重复上报
// if (adInfo.MediationId == "4")
// {
// return;
// }
// if (adInfo.NetworkFirmId == 2 && adInfo.BiddingType is not (1 or 2))
// {
// return;
// }
string adPlatform = adInfo.MediationId switch
{
"1" => "TopOn",
"2" => "Max",
"4" => "AdMob",
_ => "your ad platform",
};
var impressionParameters = new[] {
new Firebase.Analytics.Parameter("ad_platform", adPlatform),
new Firebase.Analytics.Parameter("ad_source", adInfo.NetworkName),
new Firebase.Analytics.Parameter("ad_unit_name", adInfo.NetworkPlacement),
new Firebase.Analytics.Parameter("ad_format", adInfo.Format),
new Firebase.Analytics.Parameter("value", adInfo.Revenue),
new Firebase.Analytics.Parameter("currency", adInfo.Currency),
};
Firebase.Analytics.FirebaseAnalytics.LogEvent("ad_impression", impressionParameters);
}
- 如下示例code仅供参考,详情请参考Adjust官方文档
private void OnInterstitialRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
string adPlatform = adInfo.MediationId switch
{
"1" => "topon_sdk",
"2" => "applovin_max_sdk",
"4" => "admob_sdk",
_ => "your sdk name",
};
AdjustAdRevenue adjustAdRevenue = new AdjustAdRevenue(adPlatform);
adjustAdRevenue.SetRevenue(adInfo.Revenue, adInfo.Currency);
adjustAdRevenue.AdRevenueNetwork = adInfo.NetworkName;
adjustAdRevenue.AdRevenueUnit = adInfo.NetworkPlacement;
adjustAdRevenue.AdRevenuePlacement = adInfo.Format;
Adjust.TrackAdRevenue(adjustAdRevenue);
}
- 如下示例code仅供参考,详情请参考AppsFlyer官方文档
private void OnInterstitialRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
MediationNetwork mediationNetwork = adInfo.MediationId switch
{
"1" => MediationNetwork.Topon,
"2" => MediationNetwork.ApplovinMax,
"4" => MediationNetwork.GoogleAdMob,
_ => MediationNetwork.Custom,
};
Dictionary<string, string> additionalParams = new Dictionary<string, string>();
additionalParams.Add(AdRevenueScheme.COUNTRY, adInfo.Country);
additionalParams.Add(AdRevenueScheme.AD_UNIT, adInfo.NetworkPlacement);
additionalParams.Add(AdRevenueScheme.AD_TYPE, adInfo.Format);
additionalParams.Add(AdRevenueScheme.PLACEMENT, adInfo.MediationPlacementId);
var logRevenue = new AFAdRevenueData(adInfo.NetworkName, mediationNetwork, adInfo.Currency, adInfo.Revenue);
AppsFlyer.logAdRevenue(logRevenue, additionalParams);
}
- The following sample code is for reference only. For detailed information, please refer to the official SolarEngine documentation
- The parameter description for the
ImpressionAttributesparameter shall be based on the official parameter specifications
private void OnInterstitialAdRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
ImpressionAttributes impressionAttributes = new ImpressionAttributes();
//变现平台名称
String ad_platform = adInfo.NetworkName;
//需将 ad_platform 的值转化为官方SEAdImpEventModel参数说明中定义的String值后进行使用
impressionAttributes.ad_platform = "ad_platform";
//聚合平台标识
string mediation_platform = adInfo.MediationId switch
{
"1" => "topon",
"2" => "max",
"4" => "admob",
_ => "custom",
};
//需将 mediation_platform 的值转化为官方SEAdImpEventModel参数说明中定义的String值后进行使用
impressionAttributes.mediation_platform = mediation_platform;
//变现平台的应用ID,选填项,可以填SE SDK的appKey也可以不填
impressionAttributes.ad_appid = "---SE SDK appKey---";
//变现平台的变现广告位ID
impressionAttributes.ad_id = adInfo.NetworkPlacement;
//展示广告的类型,以插屏广告为例adType = 3
impressionAttributes.ad_type = 3;
//变现平台货币类型
impressionAttributes.currency_type = adInfo.Currency;
//广告ECPM
impressionAttributes.ad_ecpm = adInfo.Revenue * 1000;
//填充成功填TRUE即可
impressionAttributes.is_rendered = true;
//如果需要设置变现广告事件的自定义属性可参官方文档示例,这里不再设置
SolarEngine.Analytics.trackAdImpression(impressionAttributes);
}