- Supported Ad Formats
- Download and Integrate
- Set Up Facebook Audience Network on the MoPub Dashboard
- Migrate Facebook Audience Network from Custom Native Setup
- Network Reporting and Auto CPM
- Test an Ad
- Data Processing Options for Users in California
- iOS 14
- Additional Support
If you plan to use the MoPub SDK to load and display ads from Facebook Audience Network via mediation, use this article for integration instructions and information unique to the ad network. To learn more about how MoPub mediation works, refer to our MoPub Network Mediation article.
Facebook Audience Network is transitioning to a Bidding only ecosystem in 2021. Audience Network will exclusively use real time bidding to fill ads in iOS apps beginning Q2 2021. Refer to Facebook’s announcement for more details. For detailed steps on how to go live with Facebook Audience Network through Advanced Bidding check our Advanced Bidding documentation.
Supported Ad Formats
Facebook Audience Network currently supports the following ad formats. For support information, visit the Facebook Audience Network homepage.
MoPub Formats | Facebook Audience Network Ad Formats |
---|---|
Banner | Banner (Note: To request banner ads with a height greater than 250, you must configure your Facebook placement as a ‘medium rectangle’ on the Facebook dashboard. Using a placement of type ‘banner’ won’t return ads in this case.) |
Medium Rectangle | Medium Rectangle |
Interstitial | Interstitial |
Rewarded Video | Rewarded Video |
Native | Native, Native Banner (see instructions below) |
Download and Integrate
To download the Facebook Audience Network adapters, navigate to the Mediation Integration Tool. You must also download the Facebook Audience Network SDK:
-
Download the Facebook Audience Network SDK for Android
For Android, Facebook Audience Network adapters are released as an Android Archive (AAR) file starting from version 5.2.0.1. The AAR includes the required Manifest data for FAN. As a result, you no longer need to update your
AndroidManifest
manually for any generic data, such as permissions and Activities. Any other app-level placement configuration required by Facebook Audience Network must be manually entered into theAndroidManifest
.
For the latest download and integration instructions, consult Facebook Audience Network’s tutorials before you integrate the SDK and adapters.
Localhost Allowlisting
Facebook uses the device’s localhost (127.0.0.1) to cache ad media files. Because Android 9 blocks cleartext traffic by default, you must add the following XML configuration to your app’s Manifest to allowlist unsecure traffic (more details here):
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
</domain-config>
Request Native Banner Ads
MoPub now supports Facebook Audience Network native banner mediation starting with v5.6.0.0 of the Android and iOS adapters. To get started, create a native banner placement on the Facebook Audience Network dashboard.
Facebook placement IDs can be enabled for native or native banner demand. Pass a flag to MoPub to indicate your preference for native or native banner demand. Follow the appropriate instructions below based for your platform and native ad integration.
Android Manual Native Ad Integration
-
In your native ad implementation, create a
Map<String, Object>
object containing your native banner preference. Set the flag’s value totrue
to request native banner, orfalse
(or don’t set it at all) to request regular native ad.Map<String, Object> localExtras = new HashMap<>(); localExtras.put("native_banner", true);
-
Pass the
Map
described above to yourMoPubNative
instance before making the ad request. Subsequently, to change your preference, repeat step 1.MoPubNative.setLocalExtras(localExtras); // Make your ad request
-
Optional: If you plan to alternate between regular native and native banner requests, we recommend that you prepare separate XML layout files, one for each format. Then, when you register your native ad renderer (because at this time you are in control of which format is requested), you can pass in the corresponding layout to your renderer. This gives you more control over the layout of your assets.
iOS Manual Native Ad Integration
-
In your native ad implementation, create an
NSDictionary
holding an{NSString : Boolean}
pair that contains your native banner preference. Set the flag’s value totrue
to request native banner, orfalse
(or don’t set it at all) to request regular native ad.NSDictionary *localExtras = @{@"native_banner" : true};
-
Pass the
NSDictionary
described above to yourMPNativeAdRequestTargeting
instance before making the ad request. Subsequently, to change your preference, repeat step 1.MPNativeAdRequestTargeting *targeting = [[MPNativeAdRequestTargeting alloc] init]; targeting.localExtras = localExtras; // Make your ad request
-
(Optional) If you plan to alternate between regular native and native banner requests, we recommend that you prepare separate layout files, one for each format. Then, when you register your native ad renderer (because at this time you are in control of which format is requested), you can pass in the corresponding layout to your renderer. This gives you more control over the layout of your assets.
Android Ad Placer Integration
-
In your app, before you initialize MoPub, create a
Map<String, String>
object containing your native banner preference. Set the flag’s value to"true"
(include the quotation marks because this API expects a String) to request native banner, or"false"
(or don’t set it at all) to request regular native ad.Map<String, String> facebookNativeBanner = new HashMap<>(); facebookNativeBanner.put("native_banner", "true");
-
In your
SdkConfiguration.Builder
, pass theMap
described above to thewithMediatedNetworkConfiguration()
call before initializing the MoPub SDK:SdkConfiguration.Builder configBuilder = new SdkConfiguration.Builder("YOUR_AD_UNIT_ID"); configBuilder.withMediatedNetworkConfiguration(FacebookAdapterConfiguration.class.getName(), facebookNativeBanner); // Initialize MoPub
iOS Ad Placer Integration
-
In your app, before you initialize MoPub, create an
NSDictionary
holding an{NSString : Boolean}
pair that contains your native banner preference. Set the flag’s value totrue
to request native banner, orfalse
(or don’t set it at all) to request regular native ad.NSDictionary * facebookConfig = @{ @"native_banner" : true};
-
In your
MPMoPubConfiguration
object, pass thatNSDictionary
to themediatedNetworkConfigurations
call before initializing the MoPub SDK:MPMoPubConfiguration * sdkConfig = [[MPMoPubConfiguration alloc] initWithAdUnitIdForAppInitialization: @"YOUR_AD_UNIT_ID"]; NSMutableDictionary * config = [@{@"FacebookAdapterConfiguration" : facebookConfig} mutableCopy]; sdkConfig.mediatedNetworkConfigurations = config; // Initialize MoPub
That’s it! When you make your ad request, we’ll inform Facebook that this is a native banner ad request.
Native Ad Advertiser Name Asset
Depending on the Facebook SDK version you are integrating, you must show only either the ad title or the advertiser name. For more information about Facebook’s implementation requirements, refer to Facebook’s article about native ads.
- To show the advertiser name asset on Android, follow our Android network integration instructions.
- If you are on iOS, adapters will automatically manage the showing of the correct asset, based on your Facebook Audience Network SDK version.
Set Up Facebook Audience Network on the MoPub Dashboard
Placement ID
is required.
Migrate Facebook Audience Network from Custom Native Setup
-
Transfer
Placement ID
(if applicable) from the old custom native connection to the supported Facebook Audience Network instance. -
MoPub will initiate the following Facebook Audience Network mediation adapter class names to render the ads:
-
iOS
FacebookBannerCustomEvent
FacebookInterstitialCustomEvent
FacebookRewardedVideoCustomEvent
FacebookNativeCustomEvent
-
Android
com.mopub.mobileads.FacebookBanner
com.mopub.mobileads.FacebookInterstitial
com.mopub.mobileads.FacebookRewardedVideo
com.mopub.nativeads.FacebookNative
If you are manually entering these class names, migrate to the new network setup and pause the Custom Native Network. If you are using your own mediation adapter class names, make sure that both the old custom native network and the new Facebook Audience Network network UI are set up for backward compatibility.
-
Important: During migration, make sure that the custom native network and the Facebook Audience Network network are not both live at the same time, because this may impact your revenue.
Network Reporting and Auto CPM
The following setup is required to take advantage of Auto CPM. To enable Facebook network reporting and Auto CPM:
-
Navigate to the MoPub UI’s Networks tab. (Refer to these additional instructions that provide more detail for the remaining steps.)
-
In the Network settings page for Facebook:
-
enable reporting access
-
provide the the System user token and Facebook business ID
For the System user token, consult this Facebook help article, with instructions on how to generate a reporting token to use in the MoPub UI.
You can find the Facebook business ID from the URL of the Facebook Business Banager or Monetization Manager portal.
If you experience problems when implementing the System User Access Token, refer to Facebook’s System User Token Generation documentation.
-
-
Navigate to the Auto CPM preferences page and turn on Auto CPM.
Test an Ad
As you test your SDK integrations and network setups, we recommend that you leverage test ad placements to ensure a consistent fill rate.
Refer to Facebook documentation to set up test mode and for details about available error codes and potential resolutions.
With test mode enabled, you can request ads using the ad unit ID you created earlier for this purpose and receive a Facebook test ad. Be sure to disable test mode after testing!
Data Processing Options for Users in California
For information about implementing Facebook’s Limited Data Use flag, refer to Facebook’s developer documentation.
iOS 14
If you are building for iOS 14 and using v6.0.0 (or newer) of the Facebook Audience Network SDK, refer to Facebook’s developer documentation for more details.
Additional Support
For inquiries and support, visit Facebook Audience Network’s support center.
Last updated December 14, 2020
TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.
© 2020 MoPub (a division of Twitter, Inc.)