Banner Ad
1. Basic requirements
Add ADX Unity SDK to your project.
Use the Ad Unit ID issued for Banner Ads.
Before requesting an ad, SDK initialization must be done first.
SDK initialization should be called only once when the app launches and ad requests should be made after SDK initialization is complete.
2. Implementation
If the app is distributed on both Android and iOS, enter the Ad Unit ID issued for each platform.
Instantiate
AdxBannerAd
and register the required callbacks.Call
Load()
to load the ad.
#if UNITY_ANDROID
string adxBannerAdUnitId = "<ANDROID_ADX_BANNER_AD_UNIT_ID>";
#elif UNITY_IOS
string adxBannerAdUnitId = "<IOS_ADX_BANNER_AD_UNIT_ID>";
#endif
void LoadBannerAd()
{
if (bannerAd != null)
{
bannerAd.Destroy();
bannerAd = null;
}
bannerAd = new AdxBannerAd(adxBannerAdUnitId, AdxBannerAd.AD_SIZE_320x50, AdxBannerAd.POSITION_TOP);
bannerAd.OnAdLoaded += BannerAd_OnAdLoaded;
bannerAd.OnAdFailedToLoad += BannerAd_OnAdFailedToLoad;
bannerAd.OnAdClicked += BannerAd_OnAdClicked;
bannerAd.Load();
}
The following POSITION
and AD_SIZE
options are supported for banner ads.
// -------- Banner Ad Size --------
// AdxBannerAd.AD_SIZE_320x50
// AdxBannerAd.AD_SIZE_728x90
// AdxBannerAd.AD_SIZE_320x100
// AdxBannerAd.AD_SIZE_300x250
// -------- Banner Ad Position --------
// AdxBannerAd.POSITION_TOP
// AdxBannerAd.POSITION_BOTTOM
// AdxBannerAd.POSITION_TOP_LEFT
// AdxBannerAd.POSITION_TOP_RIGHT
// AdxBannerAd.POSITION_BOTTOM_LEFT
// AdxBannerAd.POSITION_BOTTOM_RIGHT
// AdxBannerAd.POSITION_CENTER
3. Callback
You can receive specific events. Please implement them as needed.
public event Action OnAdLoaded = delegate { };
public event Action<int> OnAdFailedToLoad = delegate { };
public event Action OnAdClicked = delegate { };
public event Action<double> OnPaidEvent = delegate { };
4. Ad Revenue (OnPaidEvent)
You can check the estimated ad revenue for ad impressions.
bannerAd.OnPaidEvent += BannerAd_OnPaidEvent;
void BannerAd_OnPaidEvent(double ecpm)
{
double revenue = ecpm / 1000f;
// Firebase Analytics Example
var impressionParameters = new[] {
new Firebase.Analytics.Parameter("ad_platform", "AD(X)"),
new Firebase.Analytics.Parameter("ad_unit_name", "ADX Banner Ad"),
new Firebase.Analytics.Parameter("ad_format", "BannerAd"),
new Firebase.Analytics.Parameter("value", revenue),
new Firebase.Analytics.Parameter("currency", "USD")
};
Firebase.Analytics.FirebaseAnalytics.LogEvent("ad_impression", impressionParameters);
// AppsFlyer Example
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("AdUnitName", "ADX Banner Ad")
dic.Add("AdType", "BannerAd");
AppsFlyerAdRevenue.logAdRevenue("AD(X)", AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeCustomMediation, revenue, "USD", dic);
}
Last updated
Was this helpful?