Mediate via MoPub for Android¶
The Flurry mediation adapter for MoPub lets you integrate ads from the Flurry network, via the Flurry Advertising SDKs, while using the MoPub SDK. The adapter supports native, interstitial and banner ad units.
To mediate Flurry via MoPub for Android, ensure that you have access to the following:
- Flurry SDK 6.6+. See Integration Instructions.
- MoPub Android SDK, acquired from MoPub’s repository
- Flurry Android adapter for MoPub, acquired from MoPub’s repository.
- Flurry API key and ad space created on Flurry’s developer portal at https://y.flurry.com. See the Ad Unit Basic Setup guide. For native integration see Creating Native Stream Ad Spaces.
- A MoPub ad unit ID created on MoPub
Get Started Mediating Flurry via MoPub¶
To integrate Flurry as a Custom Native Network in the MoPub ad serving flow, you perform the following tasks:
- Integrate the Flurry SDK and Flurry adapter for MoPub code into your app.
- Configure Flurry’s Ad Unit(s).
- Configure MoPub to mediate Flurry.
- Request ads in your app.
Integrate Flurry SDK and Flurry adapter into Your app¶
Follow these steps:
If your app is not currently tracked by Flurry, create a new application on Flurry’s developer portal.
Keep a reference to the API Key for the new application after it has been created. Flurry requires each application to have its own unique API key to identify your app within the Flurry system. The Flurry API key is also used when configuring mediation on the MoPub dashboard.
Add the latest Flurry Android SDK into your app.
To integrate the Flurry adapter into your application code, follow the structure advised by MoPub for 3rd party ad networks:
The adapter source files, which can be acquired from MoPub, consists of the following Flurry classes:
Ensure that the com.mopub.nativeads and com.mopub.mobileads packages are available in your App where you intend to integrate MoPub mediation. If not, you’ll need to create them.
Place the following classes in com.mopub.mobileads package:
Place the following classes in com.mopub.nativeads package:
- FlurryNativeAdRenderer.java (only required for native video ads)
Note the fully qualified class name of the custom event files and the package name. You will need them when you configure the Custom Native Network on the MoPub dashboard.
Configure Flurry Ad Unit(s)¶
Follow these steps:
- For each MoPub ad unit that you want to mediate Flurry through, create a matching ad unit on the Flurry developer portal.
- Log into the developer portal and navigate to the Monetization tab. On the left navigation bar select, Applications & Ad Units.
- You may see a list of previously created ad units. To set up a new one, click the Ad Unit button in the upper-left corner. Depending on the type of Ad Unit you are creating, the Ad Unit setup screen has three to four modules. The Basic Setup section includes fields required to define the name, application, dimensions, placement and orientation of the ad unit.
- You only need the basic setup to start. Click Save.
You are required to create your ad space on the dev portal before retrieving ads through mediation.
Mediating Flurry through MoPub requires no additional Flurry-related coding. The Flurry ad unit invocation code is already incorporated in the adapter code.
If you are integrating banner ads, and would like to simplify the impressions count reconciliation, Flurry recommends that you turn off the banner refresh in Flurry and let MoPub refresh the ads. Set the refresh rate for the ad space to an unusually high number, like 9999 (instead of the default 30 seconds). This setting is found in the Advanced Options section of the ad space setup.
Configure MoPub to Mediate Flurry¶
After you incorporate the Flurry adapter source files into your project, you need to configure Flurry as a Custom Native Network into the MoPub’s mediation flow. Follow the instructions provided by MoPub.
When adding Flurry to the mediation flow, note that you need to provide the Flurry custom event fully qualified class names as noted below.
com.mopub.mobileads.FlurryCustomEventBannerfor banner ad units
com.mopub.mobileads.FlurryCustomEventInterstitialfor takeover ad units
com.mopub.nativeads.FlurryCustomEventNativefor native ad units
In the “Custom Event Class Data” column of each ad unit you are configuring to mediate Flurry, add the the Flurry API key and the name of the Flurry ad space. The parameter names are:
For example, the column would have the following value:
Request Ads in Your App¶
For native ads, note that you will need to register the FlurryNativeAdRenderer class as a custom ad renderer if you want to be able to support Flurry native video ads, in addition to static native ads. When instantiating the renderer object, you are required to pass in your ViewGroup that will display the videos.
// Set up your regular ViewBinder ViewBinder binder = new ViewBinder.Builder(R.layout.native_ad_list_item) .build(); // Configure FlurryViewBinder with your video view FlurryViewBinder flurryBinder = new FlurryViewBinder.Builder(binder) .videoViewId(R.id.native_video_view) // Register the FlurryNativeAdRenderer to handle both Flurry video and static native ads final FlurryNativeAdRenderer flurryRenderer = new FlurryNativeAdRenderer(flurryBinder); mAdAdapter = new MoPubAdAdapter(getActivity(), adapter); mAdAdapter.registerAdRenderer(flurryRenderer); //...register other native ad renderers as required
NOTE: If you do not plan to incorporate Flurry native video ads in your app, you will need to remove the FlurryNativeAdRenderer from your classpath/project.