Google AdMob

Note

This feature is currently in beta. If you have any questions or suggestions for improvements, reach out to your Airbridge CSM. If you don't have a designated CSM, contact the Airbridge Help Center.

Airbridge supports SDK integration with AdMob. With the integration, you can import the ad revenue into Airbridge.

SDK Integration

Click the link below and install the Google AdMob SDK.

Enable impression-level ad revenue

Enable impression-level ad revenue by referring to the article below.

Send ad click data to Airbridge

The code below allows you to pass the ad click data to the Airbridge SDK when the user engages with an ad.

1234567891011121314151617181920212223242526272829303132333435363738394041
- (void)load {
    GADRequest* request = [GADRequest request];
    [GADRewardedAd loadWithAdUnitID:@"ad unit ID"
                            request:request
                  completionHandler:^(GADRewardedAd *ad, NSError *error)
     {
        self.ad = ad;
        self.ad.paidEventHandler = ^void(GADAdValue *_Nonnull adValue){
            // ...
        };
    }];
}

- (void)show {
    UIViewController *yourViewController = nil;
    
    NSString* adUnitId = self.ad.adUnitID;
    NSString* adNetworkAdapter = self.ad.responseInfo.loadedAdNetworkResponseInfo.adNetworkClassName;
    
    __block GADAdReward *reward = self.ad.adReward;
    
    // Send Event
    ABInAppEvent* event = [[ABInAppEvent alloc] init];
    [event setAction:adUnitId];
    [event setCategory:@"airbridge.adClick"];
    [event setLabel:adNetworkAdapter];
    [event setSemantics:@{
        @"adPartners": @{
            @"admob": @{
                @"ad_unit_id": adUnitId,
                @"ad_network_adapter": adNetworkAdapter
            }
        },
    }];
    [event send];
    
    // Present RewardVideo Step
    [self.ad presentFromRootViewController:yourViewController userDidEarnRewardHandler:^{
        NSLog(@"Reward received with amount \(%f)", reward.amount.doubleValue);
    }];
}

Send Admob data to Airbridge

Configure data callbacks in the AdMob SDK to send ad revenue data to the Airbridge SDK.

The revenue data passed by the AdMob SDK varies depending on the platform environment. For example, for 0.005 USD, 5000 will be returned in Unity and Android, whereas 0.005 will be returned in iOS.

When using the code below, 0.005 is input as the value to the Airbridge SDK across all platforms, and 5000 in semanticAttributes.adPartners.admob.value_micros.

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);
}

Was this page helpful?

Have any questions or suggestions?