Search Unity

Question low fill rate banners

Discussion in 'Unity Mediation' started by ronmar, Nov 22, 2022.

  1. ronmar

    ronmar

    Joined:
    Aug 28, 2021
    Posts:
    11
    Hello,
    I implemented unity mediation two weeks ago with banners and a reward ad.

    With the reward ad, I'm getting a 92% fill rate on IOS and 72% on android

    But with banners, I'm getting 1.34% for Android and 7.83% for ios. any idea why?

    here is the code with some screenshots:
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using Unity.Services.Core;
    4. using Unity.Services.Mediation;
    5. using UnityEngine.Assertions.Must;
    6.  
    7.  
    8. public class AdBanner : MonoBehaviour
    9. {
    10.     [Header("Ad Unit Ids"), Tooltip("Android Ad Unit Ids")]
    11.     public string androidAdUnitId;
    12.  
    13.     [Tooltip("iOS Ad Unit Ids")] public string iosAdUnitId;
    14.  
    15.     [Header("Game Ids"),
    16.      Tooltip("[Optional] Specifies the iOS GameId. Otherwise uses the dashboard provided GameId by default.")]
    17.     public string iosGameId;
    18.  
    19.     [Tooltip("[Optional] Specifies the Android GameId. Otherwise uses the dashboard provided GameId by default.")]
    20.     public string androidGameId;
    21.  
    22.     [Header("Banner options")] public BannerAdAnchor bannerAdAnchor = BannerAdAnchor.TopCenter;
    23.  
    24.     public BannerAdPredefinedSize bannerSize = BannerAdPredefinedSize.Banner;
    25.  
    26.     IBannerAd m_BannerAd;
    27.  
    28.     public RectTransform topContainer, topStackView, topShadow;
    29.  
    30.     async void OnEnable()
    31.     {
    32.         try
    33.         {
    34.             Debug.Log("Initializing...");
    35.             if (UnityServices.State == ServicesInitializationState.Uninitialized)
    36.             {
    37.                 await UnityServices.InitializeAsync(GetGameId());
    38.             }
    39.  
    40.             Debug.Log("Initialized!");
    41.  
    42.             InitializationComplete();
    43.         }
    44.         catch (Exception e)
    45.         {
    46.             InitializationFailed(e);
    47.         }
    48.     }
    49.  
    50.     void OnDisable()
    51.     {
    52.         m_BannerAd?.Dispose();
    53.         ResetTop();
    54.     }
    55.  
    56.     private void ResetTop()
    57.     {
    58.         topContainer.sizeDelta = new Vector2(0, 171);
    59.         topStackView.offsetMax = new Vector2(0, 0);
    60.         topStackView.offsetMin = new Vector2(0, 0);
    61.         topShadow.offsetMax = new Vector2(0, -172);
    62.     }
    63.  
    64.     InitializationOptions GetGameId()
    65.     {
    66.         var initializationOptions = new InitializationOptions();
    67.  
    68. #if UNITY_IOS
    69.         if (!string.IsNullOrEmpty(iosGameId))
    70.         {
    71.             initializationOptions.SetGameId(iosGameId);
    72.         }
    73. #elif UNITY_ANDROID
    74.                 if (!string.IsNullOrEmpty(androidGameId))
    75.                 {
    76.                     initializationOptions.SetGameId(androidGameId);
    77.                 }
    78. #endif
    79.  
    80.         return initializationOptions;
    81.     }
    82.  
    83.     void InitializationComplete()
    84.     {
    85.         // Impression Event
    86.         MediationService.Instance.ImpressionEventPublisher.OnImpression += ImpressionEvent;
    87.  
    88.         var bannerAdSize = bannerSize.ToBannerAdSize();
    89.  
    90.         switch (Application.platform)
    91.         {
    92.             case RuntimePlatform.Android:
    93.                 m_BannerAd = MediationService.Instance.CreateBannerAd(androidAdUnitId, bannerAdSize, bannerAdAnchor);
    94.                 break;
    95.             case RuntimePlatform.IPhonePlayer:
    96.                 m_BannerAd = MediationService.Instance.CreateBannerAd(iosAdUnitId, bannerAdSize, bannerAdAnchor);
    97.                 break;
    98.             case RuntimePlatform.WindowsEditor:
    99.             case RuntimePlatform.OSXEditor:
    100.             case RuntimePlatform.LinuxEditor:
    101.                 m_BannerAd = MediationService.Instance.CreateBannerAd(
    102.                     !string.IsNullOrEmpty(androidAdUnitId) ? androidAdUnitId : iosAdUnitId, bannerAdSize,
    103.                     bannerAdAnchor);
    104.                 break;
    105.             default:
    106.                 Debug.LogWarning("Mediation service is not available for this platform:" + Application.platform);
    107.                 return;
    108.         }
    109.  
    110.         Debug.Log("Initialized On Start! Loading banner Ad...");
    111.         LoadAd();
    112.     }
    113.  
    114.     async void LoadAd()
    115.     {
    116.         try
    117.         {
    118.             await m_BannerAd.LoadAsync();
    119.  
    120.             AdLoaded();
    121.         }
    122.         catch (LoadFailedException e)
    123.         {
    124.             AdFailedLoad(e);
    125.         }
    126.     }
    127.  
    128.     void AdLoaded()
    129.     {
    130.         try
    131.         {
    132.             topContainer.sizeDelta = new Vector2(0, topContainer.sizeDelta.y + m_BannerAd.Size.Height);
    133.             topStackView.offsetMax = new Vector2(0, -m_BannerAd.Size.Height);
    134.             topStackView.offsetMin = new Vector2(0, -m_BannerAd.Size.Height);
    135.             var offsetMax = topShadow.offsetMax;
    136.             offsetMax = new Vector2(offsetMax.x, offsetMax.y - m_BannerAd.Size.Height);
    137.             topShadow.offsetMax = offsetMax;
    138.             topShadow.sizeDelta = new Vector2(0, 16);
    139.         }
    140.         catch (Exception e)
    141.         {
    142.             m_BannerAd?.Dispose();
    143.             ResetTop();
    144.             throw;
    145.         }
    146.  
    147.  
    148.         Debug.Log("Ad loaded");
    149.     }
    150.  
    151.     void AdFailedLoad(LoadFailedException e)
    152.     {
    153.         Debug.Log("Failed to load ad");
    154.         Debug.Log(e.Message);
    155.     }
    156.  
    157.     void ImpressionEvent(object sender, ImpressionEventArgs args)
    158.     {
    159.         var impressionData = args.ImpressionData != null ? JsonUtility.ToJson(args.ImpressionData, true) : "null";
    160.         Debug.Log($"Impression event from ad unit id {args.AdUnitId} : {impressionData}");
    161.     }
    162.  
    163.     void InitializationFailed(Exception error)
    164.     {
    165.         var initializationError = SdkInitializationError.Unknown;
    166.         if (error is InitializeFailedException initializeFailedException)
    167.         {
    168.             initializationError = initializeFailedException.initializationError;
    169.         }
    170.  
    171.         Debug.Log($"Initialization Failed: {initializationError}:{error.Message}");
    172.     }
    173. }
    ios:



    Android:

     
  2. Ortiz_Daniel

    Ortiz_Daniel

    Unity Technologies

    Joined:
    Oct 14, 2021
    Posts:
    30
    Hi @ronmar,

    Thanks for reaching out and sharing your screenshots.

    While I won't be able to assist with the implementation, I would recommend you try to include more Ad Sources/Line items to create competition in your banner waterfalls.

    Depending on where your users are banners may be hard to get fill from in general, so more competition should lead to more impressions.

    I would recommend leveraging the A/B testing tool to try out different strategies to find out what set up works best.

    Best,
    Daniel Ortiz
     
    DeclanMcPartlin likes this.