💡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
ATInterstitialAd.Instance.setAdRevenueListener("your placement id", new InterstitialAdRevenueListener());
private sealed class InterstitialAdRevenueListener : IATAdRevenueListener
{
public void onAdRevenuePaid(string placementId, ATCallbackInfo adInfo)
{
// Prevent duplicate AdMob reporting
// if (adInfo.network_firm_id == 2 && adInfo.adsource_isheaderbidding is not (1 or 2))
// {
// return;
// }
var impressionParameters = new[] {
new Firebase.Analytics.Parameter("ad_platform", "TopOn"),
new Firebase.Analytics.Parameter("ad_source", adInfo.network_name),
new Firebase.Analytics.Parameter("ad_unit_name", adInfo.network_placement_id),
new Firebase.Analytics.Parameter("ad_format", adInfo.adunit_format),
new Firebase.Analytics.Parameter("value", adInfo.publisher_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
ATInterstitialAd.Instance.setAdRevenueListener("your placement id", new InterstitialAdRevenueListener());
private sealed class InterstitialAdRevenueListener : IATAdRevenueListener
{
public void onAdRevenuePaid(string placementId, ATCallbackInfo adInfo)
{
AdjustAdRevenue adjustAdRevenue = new AdjustAdRevenue("topon_sdk");
adjustAdRevenue.SetRevenue(adInfo.publisher_revenue, adInfo.currency);
adjustAdRevenue.AdRevenueNetwork = adInfo.network_name;
adjustAdRevenue.AdRevenueUnit = adInfo.network_placement_id;
adjustAdRevenue.AdRevenuePlacement = adInfo.adunit_id;
Adjust.TrackAdRevenue(adjustAdRevenue);
}
}
- The following sample code is for reference only. For detailed information, please refer to the official AppsFlyer documentation
ATInterstitialAd.Instance.setAdRevenueListener("your placement id", new InterstitialAdRevenueListener());
private sealed class InterstitialAdRevenueListener : IATAdRevenueListener
{
public void onAdRevenuePaid(string placementId, ATCallbackInfo adInfo)
{
Dictionary<string, string> additionalParams = new Dictionary<string, string>();
additionalParams.Add(AdRevenueScheme.COUNTRY, adInfo.country);
additionalParams.Add(AdRevenueScheme.AD_UNIT, adInfo.network_placement_id);
additionalParams.Add(AdRevenueScheme.AD_TYPE, adInfo.adunit_format);
additionalParams.Add(AdRevenueScheme.PLACEMENT, adInfo.adunit_id);
var logRevenue = new AFAdRevenueData(adInfo.network_name, MediationNetwork.Topon, adInfo.currency, adInfo.publisher_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
ATInterstitialAd.Instance.setAdRevenueListener("your placement id", new InterstitialAdRevenueListener());
private sealed class InterstitialAdRevenueListener : IATAdRevenueListener
{
public void onAdRevenuePaid(string placementId, ATCallbackInfo adInfo)
{
// Interstitial ad revenue paid. Use this callback to track user revenue.
ImpressionAttributes impressionAttributes = new ImpressionAttributes();
// Monetization Network Name
String ad_platform = adInfo.network_name;
// 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
impressionAttributes.mediation_platform = "topon";
// 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.network_placement_id;
// Displayed Ad Type (If interstitial ad, adType = 3)
impressionAttributes.ad_type = 3;
// Currency
impressionAttributes.currency_type = adInfo.currency;
// Ad eCPM
impressionAttributes.ad_ecpm = adInfo.adsource_price;
// If ad is rendered successfully
impressionAttributes.is_rendered = true;
SolarEngine.Analytics.trackAdImpression(impressionAttributes);
}
}