Integrating AdMob Mediation + Vungle SDK v.5 (Android)

Contents

Before You Begin

Step 1. Set Up Vungle as an Ad Network

  1. Log into the AdMob dashboard and navigate to the Monetize tab. 

  2. Choose the app to which you want to add Vungle as an ad network.

  3. Select the ad format and add the ad unit to your app.

    • For the Interstitial ad format, select the Video option, because all Vungle ads are video ads.

      image2.png

    • For the Rewarded video ad format, select the Set a reward option and enter values in the Reward amount and Reward item Vungle does not support the Use third-party ad network settings functionality.

      image6.png

  4. Choose your ad unit and click ad sources in the Mediation column.

    image1.png

  5. Click + New Ad Network.

    image5.png

  6. Select Vungle from the left panel and enter your Vungle Application ID and matching placement ID, available on the Vungle dashboard

    image1.png

Step 2. Integrate the Vungle Adapter and SDK

  1. Download the Vungle AdMob adapter and add it to your project library.

    image3.png

  2. Update the app-level build.gradle file.
    dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])  // Vungle SDK
      compile(name:'VungleAdapter', 'ext':'aar')  // Vungle Adapter for AdMob
    }
    
    
    repositories {
      jcenter()
      flatDir {
          dirs 'libs'
      }
    }
    


  3. Follow the instructions in the “Step 1. Include the Vungle SDK in Your Project“ section of “Get Started with Vungle - Android SDK“ to add the necessary frameworks.

  4. If you need to set Multidex , Proguard, and Google Play Services, follow the instructions in the “Advanced Settings“ section of “Get Started with Vungle - Android SDK“.

Step 3. Pass a Placement Reference ID to the Adapter

With Vungle SDK version 5.1+, you must import VungleExtrasBuilder and create a Bundle object to provide the placement reference ID and all placement reference IDs to the Vungle adapter.

Note: A default placement is created for each app automatically. If you create multiple placements, provide all the reference IDs. You must provide its placement reference ID as playPlacement if you don’t set up Vungle Placement Reference ID in AdMob dashboard.

For Interstitial:

import com.vungle.mediation.VungleInterstitialAdapter; 
import com.vungle.mediation.VungleExtrasBuilder;

String[] placements = new String[] { “PLACEMENT_ID_1”, “PLACEMENT_ID_2”, “PLACEMENT_ID_3” };

Bundle extras = new VungleExtrasBuilder(placements).build();
// Required if there is no placement reference ID set up in AdMob dashboard
// Bundle extras = new VungleExtrasBuilder(allPlacements).setPlayingPlacement(“PLACEMENT_ID_FOR_THE_AD_UNIT”).build();

AdRequest adRequest = new AdRequest.Builder()
.addNetworkExtrasBundle(VungleInterstitialAdapter.class, extras)
.build();

mInterstitialAd01.loadAd(adRequest);

For Rewarded Video:

import com.vungle.mediation.VungleAdapter; 
import com.vungle.mediation.VungleExtrasBuilder;

String[] placements = new String[] { “PLACEMENT_ID_1”, “PLACEMENT_ID_2”, “PLACEMENT_ID_3” };

Bundle extras = new VungleExtrasBuilder(placements).build();
// Required if there is no placement reference ID set up in AdMob dashboard
// Bundle extras = new VungleExtrasBuilder(allPlacements).setPlayingPlacement(“PLACEMENT_ID_FOR_THE_AD_UNIT”).build();

AdRequest adRequest = new AdRequest.Builder()
.addNetworkExtrasBundle(VungleAdapter.class, extras)
.build();

mRewardedAd01.loadAd(RewardedAdUnitID01, adRequest);

Note about auto-cached ads: The Vungle SDK will cache an ad automatically for the placement you selected to be Auto Cached​ in the Vungle Dashboard. We highly recommend selecting the AdMob Ad Unit shown first or the Ad Unit shown most frequently as the Auto Cached placement.

Note about playing multiple rewarded ads: Calling RewardedVideoAd.showAd() plays the AdMob ad unit that was last called by RewardedVideoAd.loadAd(admob_ad_unit, adRequest). If you want to pre-cache multiple ads and specify which pre-cached ad to play, you can still do so by calling RewardedVideoAd.loadAd(admob_ad_unit, adRequest) for different ad units, then calling RewardedVideoAd.loadAd(admob_ad_unit, adRequest) again for the already pre-cached ads, before calling RewardedVideoAd.showAd(). As of "com.google.android.gms:play-services-ads:11.4.0", AdMob does not directly allow you to specify which pre-cached rewarded ad to play through RewardedVideoAd.showAd() as a parameter.

Passing Additional Parameters (Optional)

Interstitial Ads

You can use extra properties to customize ads.

Property

Description

userId

Sets unique user ID to be passed to Vungle SDK for use in server-to-server callback for Rewarded ads.

setSoundEnabled

Sets the starting sound state for the ad. If set to false, video begins with muted sound, but the user may modify it.

setOrdinalViewCount

If you receive ordinal data reports from Vungle, use this field to pass the mediation ordinal. This is an integer indicating the order in which this ad was shown in the game session (for example, if two ads were already shown in this session, and this ad from Vungle was then shown third, pass in '3'). Read more about ordinal data here.

setFlexViewCloseTimeInSec

Use this option to make flex view ads dismiss on their own after the specified number of seconds. 
This function only works with Flex View ads, but is not advisable in most situations. 

// sending user id ("USER_ID") and setting ad playback muted
String[] placements = {"PLACEMENT_ID_1", "PLACEMENT_ID_", "PLACEMENT_ID_3"};
Bundle extras = new VungleExtrasBuilder(placements).setUserId("USER_ID").setSoundEnabled(false)
.setOrdinalViewCount(3).setPlayingPlacement("PLACEMENT_ID_1").build();
AdRequest adRequest = new AdRequest.Builder()
       .addNetworkExtrasBundle(VungleInterstitialAdapter.class, extras)
       .build();

mInterstitialAd01.loadAd(adRequest);

Rewarded Ads

You can use extra parameters to customize Rewarded ads.

Property

Description

setUserId

Sets unique user ID to be passed to Vungle SDK for use in server-to-server callback for Rewarded ads.

withSoundEnabled

Sets the starting sound state for the ad. If set to false, video begins with muted sound, but the user may modify it.

setOrdinalViewCount

If you receive ordinal data reports from Vungle, use this field to pass the mediation ordinal. This is an integer indicating the order in which this ad was shown in the game session (for example, if two ads were already shown in this session, and this ad from Vungle was then shown third, pass in '3'). Read more about ordinal data here.

setViewCloseTimeInSec

Sets the number of seconds the Flex View videos will play before they automatically close.

 

Have more questions? Submit a request

Comments