💡Tips
- 🟢 This example uses interstitial ad format for demonstration. Other ad formats follow the same implementation logic
- 🔵 Callback parameters are for reference only. Select appropriate parameters according to your business requirements
- ⚠️ When using Link AdMob to Firebase, avoid duplicate AdMob revenue reporting
- The following sample code is for reference only. For detailed information, please refer to the official Firebase documentation
private void OnInterstitialRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// Prevent duplicate AdMob reporting
// if ("AdMob".Equals(adInfo.NetworkName, StringComparison.OrdinalIgnoreCase)) return;
string adPlatform;
if (adInfo.MediationId == nameof(McSdkBase.MediationId.TopOn)) {
ad_platform = "TopOn";
} else if (adInfo.MediationId == nameof(McSdkBase.MediationId.Max)) {
ad_platform = "Max";
} else {
ad_platform = "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);
}
- The following sample code is for reference only. For detailed information, please refer to the official Adjust documentation
private void OnInterstitialRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
string adPlatform;
if (adInfo.MediationId == nameof(McSdkBase.MediationId.TopOn)) {
ad_platform = "topon_sdk";
} else if (adInfo.MediationId == nameof(McSdkBase.MediationId.Max)) {
ad_platform = "applovin_max_sdk";
} else {
ad_platform = "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);
}
- The following sample code is for reference only. For detailed information, please refer to the official AppsFlyer documentation
private void OnInterstitialRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
MediationNetwork mediationNetwork;
if (adInfo.MediationId == nameof(McSdkBase.MediationId.TopOn)) {
mediationNetwork = MediationNetwork.Topon;
} else if (adInfo.MediationId == nameof(McSdkBase.MediationId.Max)) {
mediationNetwork = MediationNetwork.ApplovinMax;
} else {
mediationNetwork = 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)
{
// Interstitial ad revenue paid. Use this callback to track user revenue.
ImpressionAttributes impressionAttributes = new ImpressionAttributes();
// Monetization Network Name
String ad_platform = adInfo.NetworkName;
// Please map the value of `ad_platform` to the String value defined in the official SEAdImpEventModel parameter specifications before use
impressionAttributes.ad_platform = "ad_platform";
// Mediation Platform Name
string mediation_platform;
if (adInfo.MediationId == nameof(McSdkBase.MediationId.TopOn)) {
mediation_platform = "topon";
} else if (adInfo.MediationId == nameof(McSdkBase.MediationId.Max)) {
mediation_platform = "max";
} else {
mediation_platform = "custom";
}
// Please map the value of `mediation_platform` to the String value defined in the official SEAdImpEventModel parameter specifications before use
impressionAttributes.mediation_platform = mediation_platform;
// Monetization Platform App ID (optional) You can input the appKey in SE SDK
impressionAttributes.ad_appid = "---SE SDK appKey---";
// Monetization Network Ad ID
impressionAttributes.ad_id = adInfo.NetworkPlacement;
// Displayed Ad Type (If interstitial ad, adType = 3)
impressionAttributes.ad_type = 3;
// Currency
impressionAttributes.currency_type = adInfo.Currency;
// Ad eCPM
impressionAttributes.ad_ecpm = adInfo.Revenue * 1000;
// If ad is rendered successfully
impressionAttributes.is_rendered = true;
SolarEngine.Analytics.trackAdImpression(impressionAttributes);
}