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:

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:

  1. Integrate the Flurry SDK and Flurry adapter for MoPub code into your app.
  2. Configure Flurry’s Ad Unit(s).
  3. Configure MoPub to mediate Flurry.
  4. Request ads in your app.

Integrate Flurry SDK and Flurry adapter into Your app

Follow these steps:

  1. If your app is not currently tracked by Flurry, create a new application on Flurry’s developer portal.

  2. 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.

  3. Add the latest Flurry Android SDK into your app.

  4. 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:

    • FlurryAgentWrapper.java
    • FlurryCustomEventBanner.java
    • FlurryCustomEventInterstitial.java
    • FlurryCustomEventNative.java
    • FlurryNativeAdRenderer.java
    • FlurryViewBinder.java

    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:

    • FlurryAgentWrapper.java
    • FlurryCustomEventBanner.java
    • FlurryCustomEventInterstitial.java

    Place the following classes in com.mopub.nativeads package:

    • FlurryCustomEventNative.java
    • FlurryNativeAdRenderer.java (only required for native video ads)
    • FlurryViewBinder.java
  5. 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:

  1. For each MoPub ad unit that you want to mediate Flurry through, create a matching ad unit on the Flurry developer portal.
  2. Log into the developer portal and navigate to the Monetization tab. On the left navigation bar select, Applications & Ad Units.
  3. 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.
Flurry ad unit creation screen
  1. You only need the basic setup to start. Click Save.

For additional ad unit configuration, see Basic ad unit setup instructions and Advanced ad space setup instructions.

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.FlurryCustomEventBanner for banner ad units
  • com.mopub.mobileads.FlurryCustomEventInterstitial for takeover ad units
  • com.mopub.nativeads.FlurryCustomEventNative for 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:

  • apiKey
  • adSpaceName

For example, the column would have the following value:

{"apiKey":"YOUR_API_KEY","adSpaceName":"YourAdUnitName"}

MoPub line item configuration

Request Ads in Your App

In general, you should follow the instructions for integration of banner ads, integration of interstitial ads, or integration of native ads from MoPub.

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.