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 dedicated CSM, contact us through the Airbridge Help Center.

Airbridge supports SDK integration with Google 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 in Google Admob

The impression-level ad revenue should be enabled in Google AdMob to send ad revenue data to Airbridge. Refer to the following article on enabling impression-level ad revenue.

Send Google AdMob 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 Google AdMob ad revenue data to Airbridge

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

The ad revenue data passed by the Google AdMob SDK varies depending on the platform. For example, for 0.005 USD, 5000 will be returned in Unity and Android, whereas 0.005 will be returned in iOS. By using the code below, 0.005 will be sent to Airbridge SDK for all platforms. The micro dollar value, which is 5000 in this case, will be sent as 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?