Google AdMob Ad Revenue Integration

    This integration enables Airbridge to collect Google AdMob ad revenue data. The data can be shown on the Airbridge dashboard by attribution and user.

    AdMob ad revenue data is collected from the AdMob SDK and sent to the Airbridge SDK. "Impression-level ad revenue" in the AdMob dashboard must be configured in order to collect data. Please make sure that the AdMob SDK is installed and that the "Impression-level ad revenue" is activated.

    AdMob SDK Installation

    AdMob "Impression-level ad revenue" Setup

    Forwarding AdMob Ad Revenue Data to Airbridge

    Please setup data callbacks to send ad revenue data to the Airbridge SDK, using the AdMob SDK.

    12345678910111213141516171819202122232425262728293031323334353637
    private void RequestRewardedAd()
    {
        RewardedAd.LoadAd(adUnitId, new AdRequest.Builder().Build(), (rewardedAd, error) => {
            if (error != null) { return; }
    
            this.rewardedAd = rewardedAd;
            this.rewardedAd.OnPaidEvent += this.HandleAdPaidEvent;
        }
    }
    
    public void HandleAdPaidEvent(object sender, AdValueEventArgs args)
    {
        AdValue adValue = args.AdValue;
        var adUnitId = this.rewardedAd.adUnitId;
        var adNetworkAdapter = this.rewardedAd.MediationAdapterClassName();
      
        AirbridgeEvent @event = new AirbridgeEvent("airbridge.adImpression");
    
        var admob = new Dictionary<string, object>();
        admob["value_micros"] = adValue.Value;
        admob["currency_code"] = adValue.CurrencyCode;
        admob["precision"] = adValue.Precision;
      
        admob["ad_unit_id"] = adUnitId;
        admob["ad_network_adapter"] = adNetworkAdapter;
         
        var adPartners = new Dictionary<string, object>();
        adPartners["admob"] = admob;
      
        @event.SetAction(adUnitId);
        @event.SetLabel(adNetworkAdapter);
        @event.SetValue(adValue.Value / 1000000.0);
        @event.AddSemanticAttribute("adPartners", adPartners);
        @event.AddSemanticAttribute("currency", adValue.CurrencyCode);
      
        AirbridgeUnity.TrackEvent(@event);
    }

    The AdMob SDK passes revenue data differently depending on the platform environment. A revenue of $0.005 will return 5000 in the Unity, Android. The same revenue will return 0.005 in the iOS.
    The example code above guides you to enter 0.005 as the value in the Airbridge SDK and 5000 in semanticAttributes.adPartners.admob.value_micros for all platforms.

    Was this page helpful?

    Have any questions or suggestions?