At a glance: The AppsFlyer ad revenue SDK connector works with the Google Mobile Ads (GMA) SDK to report ad revenue with impression-level granularity. Note! This SDK connector is deprecated as of AppsFlyer SDK V6.9+, and is replaced by the generic ad revenue SDK connector. This version continues to work for earlier SDK versions, but will not be updated or changed.
Impression-level ad revenue reporting by SDK
Ad revenue reporting options
Ad revenue is reported to AppsFlyer by AdMob by either aggregate granularity (via API) or impression-level granularity (via SDK). Impression-level data via SDK:
- Has better data freshness and earlier availability in AppsFlyer.
- Supports SKAN.
This document details how to send impression-level ad revenue provided by AdMob in the app, to AppsFlyer.
Reporting ad revenue using the GMA SDK
SDK principles of operation
The AppsFlyer ad revenue SDK connector for AdMob automatically collects impression revenue data provided by the GMA SDK. An ad revenue event, af_ad_revenue, is generated within the platform and the event is recorded with the revenue attributed to the original UA source.
In the platform, a batch process extracts the attribution for each device, and revenue attribution is performed.
Data display
The af_ad_revenue event is used to identify ad revenue. This event is used throughout the platform, including the dashboard and data delivery tools.
Considerations when migrating from API to SDK
If you currently receive ad revenue by API from integrated partners that are mediated by AdMob, you can continue to do so. However, make sure that in the AppsFlyer platform you disable the integration with these partners when you implement the GMA monetization SDK. If you don't, ad revenue attribution may be duplicated.
If you currently send ad revenue in-app events without revenue, for recording purposes only, you can continue sending them or disable them. In any event, they don't impact the allocation of impression-level revenue in the dashboard.
Note: Some time can pass from the time you release the app version containing the ad revenue SDK to the app stores until your app users download the updated version. As such, leave the SDK module dormant and activate it after most of the users have updated the app. When you activate the module:
- Simultaneously disable the ad revenue integration of partners who mediate through AdMob
- In AppsFlyer, select impression level in the AdMob ad revenue tab.
Implementing AppsFlyer ad revenue SDK
Implementing ad revenue SDK with AdMob
Step | Action required |
---|---|
1 |
Ask your AdMob account manager to enable AdMob impression-level LTV (iLTV). |
2 | Verify that you use GMA SDK 8.12.0 or higher for Android or iOS and that the version supports iLTV. |
3 | Enable SDK-level ad revenue in AppsFlyer. Note: This needs to be done for each app individually. |
4 | Integrate the AppsFlyer ad revenue SDK using the instructions in the following section. The integration for iOS and Android is somewhat different, so make sure you follow the separate instructions. |
5 |
To switch (migrate) from API ad revenue reporting to SDK ad revenue reporting, see considerations when migrating from API to SDK in this article. |
Ad revenue SDK module for developers
Note
Currently, the ad revenue SDK only supports integration with AdMob and MoPub.
Prerequisites
- Enable iLTV for your AdMob account
- Use AppsFlyer SDK version 6.4.2+. You can find the latest version here.
- Integrate GMA SDK version 8.12.0+ into the app:
Import the Android ad revenue SDK
- Add the code below to Module-level /app/build.gradle before
dependencies
:repositories { mavenCentral() }
- Add com.appsflyer:adrevenue:6.4.2 as a dependency:
dependencies { implementation 'com.appsflyer:adrevenue:6.4.2' }
- Sync the project to retrieve the dependencies.
Initialize the Android ad revenue SDK
The following takes place inside the app global application class.
- In the app global class, inside the
onCreate
method, place the following code:
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); AppsFlyerAdRevenue.Builder afRevenueBuilder = new AppsFlyerAdRevenue.Builder(Application: this); afRevenueBuilder.addNetworks(AppsFlyerAdRevenueWrapperType.GOOGLE_ADMOB); //Optional afRevenueBuilder.adEventListener(new Consumer() { @Override public void accept(AppsFlyerAdEvent appsFlyerAdEvent) { appsFlyerAdEvent.getAdNetworkEventType(); appsFlyerAdEvent.getAdNetworkActionName(); appsFlyerAdEvent.getAdNetworkPayload(); appsFlyerAdEvent.getAdNetworkName(); } }); AppsFlyerAdRevenue.initialize(afRevenueBuilder.build()); AppsFlyerAdMobWrapper afAdRevenueGoogle = AppsFlyerAdRevenue.adMobWrapper(); … // Per each ad object (i.e Banner, Interstitial, Native, AppOpen etc) ad.setAdListener(new AdListener() { @Override public void onAdLoaded() { ad.setOnPaidEventListener(adValue -> afAdRevenueGoogle.recordImpression(adView, adValue)); }
Import the iOS ad revenue SDK using CocoaPods
- In your Podfile specify the following:
use_frameworks! pod 'AppsFlyer-AdRevenue-Admob'
Important!
If you have
pod 'AppsFlyerFramework'
in your Podfile - remove it to avoid a collision. - Run pod update.
Initialize the iOS ad revenue SDK
- In your AppDelegate.m (or AppDelegate.swift) add the following code:
@import AppsFlyerLib; @import AppsFlyerAdRevenue; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Setup AppsFlyer [[AppsFlyerLib shared] setAppsFlyerDevKey:@"{dev-key}"]; [[AppsFlyerLib shared] setAppleAppID:@"{apple-id}"]; [[AppsFlyerLib shared] setIsDebug:YES]; // Setup AppsFlyerAdRevenue [AppsFlyerAdRevenue start]; //... } - (void)applicationDidBecomeActive:(UIApplication *)application { [[AppsFlyerLib shared] start]; }
import AppsFlyerAdRevenue import AppsFlyerLib func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Setup AppsFlyer AppsFlyerLib.shared().appsFlyerDevKey = "{dev-key}" AppsFlyerLib.shared().appleAppID = "{apple-id}" AppsFlyerLib.shared().isDebug = true // Setup AppsFlyerAdRevenue AppsFlyerAdRevenue.start() } func applicationDidBecomeActive(_ application: UIApplication) { AppsFlyerLib.shared().start() }
- In your UIViewController, where you use AdMob Ad, import the ad revenue SDK:
@import AppsFlyerAdRevenueAdMob;
import AppsFlyerAdRevenueAdMob
- In your UIViewController, replace the setPaidEventHandler method with the AppsFlyer event handler:
+ (void)setPaidEventHandlerForTarget:(id)target // The ad itself, meaning the banner, interstitial, native, rewarded, app open adUnitId:(NSString *)adUnitId eventHandler:(AdMobEventHandler)eventHandler; // The completion handler. If you want to do something with the GADAdValue object after we process it. // Change this in accordance with the ad type. The example that follows is for a banner: self.bannerView = [[GADBannerView alloc] initWithAdSize:GADAdSizeBanner; // // ...Banner configurations // [AppsFlyerAdRevenueAdMob setPaidEventHandlerForTarget:self.bannerView adUnitId:@"ca-app-pub-id" eventHandler:^(GADAdValue * _Nonnull value) { // do more actions with GADAdValue }];
bannerView = GADBannerView(adSize: kGADAdSizeBanner) bannerView.adUnitID = "ca-app-pub-id" AppsFlyerAdRevenueAdMob.setPaidEventHandlerForTarget(bannerView, adUnitId: "ca-app-pub-id") { GADAdValue in // more code }
Traits and limitations
Trait | Remarks |
---|---|
Ad revenue value | Impression events with revenue values above $10 (and the equivalent in other currencies) aren't processed by the SDK connector. |