This guide is intended for publishers who want to use the Google Mobile Ads SDK to load and display ads from the Facebook Audience Network via mediation. It covers how to add Facebook ads to an ad unit's mediation configuration, and how to integrate the Facebook Audience Network SDK and adapter into an Android app.
Supported formats and features
The AdMob mediation adapter for the Facebook Audience Network has the following capabilities:
| Formats | |
|---|---|
| Banners | |
| Interstitials | |
| Rewarded video | |
| Native Advanced | |
| Features | |
| Smart banners | |
| Ad Network Optimization (ANO) | |
Requirements
- Android SDK 4.0 (API level 14) or higher
- Google Play services 9.2 or higher
Step 1: Set up Facebook Audience Network
First, sign up and log in to your Facebook developer account. Navigate to My Apps page by clicking on the My Apps button on the top right corner. Add your app to the Facebook console by clicking the + Add a New App button.

Fill out the form and click Create App ID to add your app to Facebook.

Next, in the Facebook dashboard for your app, add Facebook Audience Network to your app by clicking the + Add Product under PRODUCTS on the left sidebar and clicking Get Started for Audience Network.

Now create a placement to be used with AdMob mediation. We recommend creating a new placement for mediation with AdMob even if you have a placement already. To create a new placement, navigate to Audience Network > Placements under PRODUCTS on the left sidebar and click Create Ad Placement.

For additional instructions on creating an ad placement, select the tab corresponding to your preferred ad format.
Banner
Enter your placement's Name and Steps to Trigger an Ad when prompted.

Select Banner as the Display Format. Toggle the Refresh Rate Handled by Mediation switch to Yes and set how you want to optimize your ads. Double-check that the Status dropdown at the top of the form is set to Enabled, then click Save to create your placement.
Interstitial
Enter your placement's Name and Steps to Trigger an Ad when prompted.

Select Interstitial (App Only) as the Display Format. Set how you want to optimize your ads. Double-check that the Status dropdown at the top of the form is set to Enabled, then click Save to create your placement.
Native
Enter your placement's Name and Steps to Trigger an Ad when prompted.

Select Native as the Display Format. Click Show advanced options to reveal more options. Toggle the Carousel Ads switch and Video Ads switch to Off. Set how you want to optimize your ads. Double-check that the Status dropdown at the top of the form is set to Enabled, then click Save to create your placement.
Once the ad placement is created, locate the Placement ID under the Active Placements tab.

We will use this Placement ID to set up your AdMob ad unit ID for mediation in the next section.
Step 2: Configure mediation settings for your AdMob ad unit
You need to add Facebook to the mediation configuration for your ad unit. First sign in to your AdMob account.
Next, follow the instructions for either AdMob or AdMob Beta depending on which version of the AdMob UI you're using.
AdMob
Navigate to the Monetize tab and select your app from the list of All apps on the left-hand side. Click the link in the mediation column for the ad unit you want to mediate to Facebook.

Click + NEW AD NETWORK.

Select Facebook Audience Network from the list of networks provided and enter the Placement ID obtained in the previous section.

Click Continue at the bottom of the page to complete adding the network. Enter an eCPM value for Facebook Audience Network and click Save.
AdMob Beta
Navigate to the Mediation tab. If you have an existing mediation group you'd like to modify, click the name of that mediation group to edit it, and skip ahead to Add Facebook Audience Network as an ad source.
To create a new mediation group, select Create Mediation Group.

Enter your ad format and platform, then click Continue.

Give your mediation group a name, and select locations to target. Next, set the mediation group status to Enabled. Then click Add Ad Units, which will open up the ad unit selection overlay.

Associate this mediation group with your existing AdMob ad unit. Then click Done.

You should now see the ad units card populated with the ad units you selected.

Add Facebook Audience Network as an ad source
In the Ad Sources card, select Add Ad Network. Then select Facebook Audience Network.
Then enter an eCPM value for Facebook Audience Network and click Continue.

Next, enter the Placement ID obtained in the previous section. Then click Done.

Finally, click Save.
Step 3: Import the Facebook Audience Network SDK and adapter
Android Studio integration (recommended)
Add the following compile dependencies with the latest versions of the Facebook Audience Network SDK and adapter in the app-level build.gradle file:
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:xx.x.x'
compile 'com.google.android.gms:play-services-ads:11.0.2'
compile 'com.facebook.android:audience-network-sdk:4.24.0'
compile 'com.google.ads.mediation:facebook:4.24.0.0'
}
...
Manual integration
Download the latest version of the Facebook SDK for
Android and extract the
AudienceNetwork.aar under the AudienceNetwork/bin folder and add it to your
project.
Download the latest .aar file of the adapter from Bintray, located under the Files tab, and add it to your project.
Step 4: Additional code required
No additional code required for Facebook integration.
Step 5: Test your implementation
Facebook ads can be tested by adding the tester's Facebook account as a Tester under the Roles tab on the left-hand side in your Facebook app's dashboard (Administrator or Developer role will also be able to test the ads). The tester will need to log in to the Facebook app on a test device to begin testing. See the Testing Audience Network Implementation guide for more details.

That's it! You now have a working mediation integration with Facebook's Audience Network.
Optional steps
Using native ads
Some Facebook native ad assets don't map one to one to Google native ad assets.
Such assets are passed back to the publisher in a bundle in getExtras() method
in NativeAppInstallAd and NativeContentAd. For example, to use the subtitle
asset provided by Facebook, you should call getExtras() to get the extras
bundle and then fetch the value for the key
FacebookAdapter.KEY_SUBTITLE_ASSET.
Example:
Bundle extras = nativeAppInstallAd.getExtras();
if (extras.containsKey(FacebookAdapter.KEY_SUBTITLE_ASSET)) {
String subtitle = extras.get(FacebookAdapter.KEY_SUBTITLE_ASSET);
...
}
Bundle viewAttributes = extras.getBundle(FacebookAdapter.KEY_AD_VIEW_ATTRIBUTES);
if (viewAttributes != null) {
boolean autoplay = viewAttributes.getBoolean(FacebookAdapter.KEY_AUTOPLAY);
...
}
The following are a list of Extra Keys for Facebook specific assets:
FacebookAdapter.KEY_IDforgetId().FacebookAdapter.KEY_SOCIAL_CONTEXT_ASSETforgetAdSocialContext().FacebookAdapter.KEY_SUBTITLE_ASSETforgetAdSubtitle().- View attributes: Facebook native ad view attributes are provided as a
bundle in the extras bundle. Use
extras.getBundle(FacebookAdapter.KEY_AD_VIEW_ATTRIBUTES)to get the bundle containing the attributes obtained fromgetAdViewAttributes(). The view attributes bundle contains the following attributes:FacebookAdapter.KEY_AUTOPLAYforgetAdViewAttributes().getAutoplay().FacebookAdapter.KEY_BACKGROUND_COLORforgetAdViewAttributes().getBackgroundColor().FacebookAdapter.KEY_BUTTON_BORDER_COLORforgetAdViewAttributes().getButtonBorderColor().FacebookAdapter.KEY_BUTTON_COLORforgetAdViewAttributes().getButtonColor().FacebookAdapter.KEY_BUTTON_TEXT_COLORforgetAdViewAttributes().getButtonTextColor().FacebookAdapter.KEY_DESCRIPTION_TEXT_COLORforgetAdViewAttributes().getDescriptionTextColor().FacebookAdapter.KEY_DESCRIPTION_TEXT_SIZEforgetAdViewAttributes().getDescriptionTextSize().FacebookAdapter.KEY_TITLE_TEXT_COLORforgetAdViewAttributes().getTitleTextColor().FacebookAdapter.KEY_TITLE_TEXT_SIZEforgetAdViewAttributes().getTitleTextSize().- Typeface extras are provided as a bundle inside the attributes bundle.
Use the
FacebookAdapter.KEY_TYPEFACEkey to get the bundle containing typeface information obtained fromgetAdViewAttributes().getTypeface(). The typeface bundle contains the following extras:FacebookAdapter.KEY_IS_BOLDforgetAdViewAttributes().getTypeface().isBold().FacebookAdapter.KEY_IS_ITALICforgetAdViewAttributes().getTypeface().isItalic().FacebookAdapter.KEY_STYLEforgetAdViewAttributes().getTypeface().getStyle().
Network-specific parameters
The Facebook adapter supports an additional request parameter for native ads
which can be passed to the adapter using the FacebookExtrasBundleBuilder
class. The FacebookExtrasBundleBuilder includes the following method:
setNativeAdChoicesIconExpandable(bool)- Native ads only: Facebook provides an ability to set an expandable AdChoices icon. The AdChoices icon rendered by the adapter is expandable by default.
Here's a code example of how to set these ad request parameters:
Bundle extras = new FacebookAdapter.FacebookExtrasBundleBuilder()
.setNativeAdChoicesIconExpandable(false)
.build();
AdRequest adRequest = new AdRequest.Builder()
.addNetworkExtrasBundle(FacebookAdapter.class, extras)
.build();
adLoader.loadAd(adRequest);
Ad Rendering
The Facebook adapter populates the following Native App install ad display fields for a NativeAppInstallAd:
| Field | Populated by Facebook adapter |
|---|---|
| Headline | |
| Image | |
| Body | |
| App icon | |
| Call to action | |
| Star rating | |
| Store | |
| Price |
The Facebook adapter is built to return app install ads via Google mediation. Facebook does not return content ads. However, the Facebook adapter requires both App Install ads and Content ads to be requested.
Impression and Click Tracking
Google Mobile Ads SDK uses the Facebook Audience Network SDK's callbacks for impression and click tracking, so the reports on both the dashboard should matchup with little to no discrepancies.