Adding Third Party Ad Networks

Smaato as primary (Client Side Mediation)

Client side mediation (aka SDK mediation) enables you to mediate owned 3rd party network accounts (such as AdMob, MoPub, iAd, Millennial Media, or any other network via a custom SDK connector) via SDK. Just integrate our SDK as per the above, integrate the respective 3rd party SDK as described below and configure your network mediation in your SPX account.

CustomMediationNetwork Adapter Ad

Add your custom method to get invoked through SPX portal and the signature of the method is fixed as shown in the Sample Adapter files.

Configure the Class name along with the package name com.smaato.soma.mediation.CustomMediationBannerAdapterSample,Method name and parameters in SPX portal,

Smaato as secondary

AdMob/DFP

Import the SDK

1. First of all we need to import Soma SDK to the project.

Copy soma sdk into your project.

Right click on your project then properties.

Navigate to JavaBuildPath -> Libraries.

Click on add JARs then choose soma sdk jar.

PS: You also need to import the AdMob SDK.

2. The second thing to do is to copy and past AdMobMediationAdapter into your project (In this tutorial we will put it inside “com.smaato.soma.MediationAdapter” package, the adapter is included in the sdk zip file).

Fill in the form with a name, platform (Android), Ad Size and an Automatic Refresh then click on Save & Continue again Continue.

Now you created you Add network mediation placement, now you should create a custom event by clicking on “Add Custom Event”

Choose a Label , in Class Name field enter this class name “com.smaato.soma.MediationAdapter.AdMobMediationAdapter” and use the parameter to transfer your Smaato publisher and AdSpace Ids, the parameters should have this form “publisher=yourPublisherID&adspace=yourAdSpaceID”.

Now you are done, to get Smaato ad now you have just to use the Mediation ID in your app and this while creating a new adView (activity, adSize, “mediationId”).

4. For DFP - head over to your DFP account:

Create a new order and new line item, targeting the desired ad unit with this line item

Under that order and line item, add a new creative by clicking "Add Creatives"

Select "SDK mediation" to configure the SDK

Choose a "name" for the creative

Toggle the "Location data" to "Active"

For "Select network", choose "Custom Event"

Use the "Parameter" field to transfer your Smaato publisher and adspace IDs, in the form “publisher=yourPublisherID&adspace=yourAdSpaceID”

Choose a name in the "Label" field

In the "Class Name" field, enter this class name “com.smaato.soma.MediationAdapter.AdMobMediationAdapter”

Click "Save" to save the creative

The Smaato SDK will now be called as specified for the targeted ad units

Integrating Unity with AdMob Mediation Adapter

Prerequisite :

AdMob SDK integrated in your Unity project.

Smaato Android SDK. Steps:

This is very simple and just needs a few steps to be done. All what you need to do here, is following :

Create a library project in your IDE (e.g.Eclipse or AndroidStudio)

Copy paste the AdMob mediation Adapter to the package that you want to use

Make all the modification needed in the mediation adapter (e.g.choose the ad dimension)

Copy/Paste the generated .jar file from the /bin folder to

/Assest/Plugins/Android in your unity project

Run the unity project.

That’s it.

Mopub

MoPub Adapter Compatibility Matrix

Smaato SDK

Version

Mopub SDK version 4.7.0

Mopub SDK version 4.12.0

Mopub SDK version 4.13.0

MoPub SDK version 4.15

Formats

Banner

Adapter

Interstitial

Adapter

Native

Adapter

Banner

Adapter

Interstitial

Adapter

Native

Adapter

Banner

Adapter

Interstitial

Adapter

Native

Adapter

Banner Adapter

Interstitial Adapter

Native Adapter

Rewarded Video Adapter

Interstitial Video Adapter

v 6.1.1

supported

supported

not supported

supported

supported

supported

supported

supported

supported

supported

supported

supported

supported

supported

v 6.0.0

supported

supported

not supported

supported

supported

supported

supported

supported

supported

supported

supported

supported

not supported

not supported

v 5.1.2

supported

supported

supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

v 5.1.1

supported

supported

supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

not supported

MoPub ID configuration

First, we'll walk you through creating a MoPub ID and configuring it to work with the Smaato SDK.

Login in to https://app.mopub.com, after that click on the Inventory Tab. Then click on the Add a New App button.

Android App Setup

Add the SmaatoMopubNativeCustomEvent.java file and place it inside the package com.smaato.soma.mopubcustomevent in your App.

Edit the SmaatoMopubNativeCustomEvent.java class if you need any customization.

Interstitial Ads

MoPub Custom Events supported by Smaato's Interstitial Adapter:

showInterstitial()

onInterstitialLoaded()

onInterstitialFailed(MoPubErrorCode)

onInterstitialShown()

onInterstitialDismissed()

onInterstitialClicked()

For interstitial ads, the process is mostly similar to the aforementioned banner and native ads:

Create a Custom Native Network on MoPub dashboard (or use your existing one from the previous steps).

Enter com.smaato.soma.mopubcustomevent.SomaMopubAdapterInterstitial in the field "CUSTOM EVENT CLASS"

Enter {"publisherId": "0","adspaceId": "0"} in the "CUSTOM EVENT CLASS DATA" field. This will show a demo Interstitial ad from Smaato. So, please update it according to your publisher id and adspace id.

Add the SomaMopubAdapterInterstitial.java file and place inside the package com.smaato.soma.mopubcustomevent in your App.

Edit SomaMopubAdapterInterstitial.java class if you need any customization.

If you need any customization to decide on when to show the Ad, update the listener methods as needed. For example, if you would like to show SmaatoAd, only when calling mMoPubInterstitial.show(), update the onReadyToShow() method as per the following:

a reward success is passed, using NO_REWARD_LABEL and DEFAULT_REWARD_AMOUNT

onRewardedVideoLoadSuccess

onReadyToShow SOMA SDK callback

onRewardedVideoClicked

onWillOpenLandingPage SOMA SDK callback

only applies to end card clicks as reward videos are not clickable

onRewardedVideoClosed

onWillClose SOMA SDK callback

onRewardedVideoLoadFailure

onFailedToLoadAd SOMA SDK callback

Error code MoPubErrorCode.UNSPECIFIED is used

The "thirdPartyId" required for all MoPub callbacks is the SOMA Ad Space ID.

For rewarded video ads, the process is mostly similar to video and interstitial ads:

Create a Custom Native Network on MoPub dashboard (or use your existing one from the previous steps).

Enter com.smaato.soma.mopubcustomevent.SomaMopubRewardedVideoAdapter in the field "CUSTOM EVENT CLASS"

Enter {"publisherId": "0","adspaceId": "3090"} in the "CUSTOM EVENT CLASS DATA" field. This will show a demo rewarded video ad from Smaato. So, please update it according to your publisher id and adspace id.

Using Targeting Data

The BannerView allows developers to set the following metadata:

KeywordSearch: Tags set by the app developer that describe the type of content (e.g. cars, news, restaurants, new york…)

QuerySearch: A search term or keywords entered by the user (e.g. restaurant new york). For example, if there is a search bar in your app, when end users search for restaurant, you can pass the query string to search terms.

Age, gender: The age and gender of the user (e.g. gathered through user registration).

Setting a keyword list:

mBanner.getUserSettings().setKeywordList(“Android,California”); //connect different terms with “,”

Destroying the Banner View

After you finish using the Banner View, it is highly recommended to clean up the memory, please call the destroy() method as per the following:

@Override
public void onDestroy(){
// Need to be included while using Mediation
if(mBannerView!=null)
mBannerView.destroy();
super.onDestroy();
}

Banner Auto Reload

The BannerView is the only banner type which implement an auto reload system. The auto refresh timer is automatically deactivated as soon as the banner is off screen. The auto reload frequency is by default set to 60 seconds, you can modify this frequency using the following method

mBanner.setAutoReloadFrequency(autoReloadFrequency);

where auto reload frequency is an integer which represent the refresh frequency in seconds that can have a minimal value 10 and maximal value 240.If you wish to disable the auto reload frequency, please use the following method

BannerView:loadNewBanner=”true” need to be always the last line, otherwise the banner view will trigger a banner request ignoring all other followings attributes.

Available Parameters

Additional Parameters that can be set

Value Range

Description

BannerView:age=”30″

Integer

The user’s age

BannerView:autoReloadFrequency=”60″

Integer

Set the auto refresh. Minimum = 10sec. Maximum = 600sec.

BannerView:backgroundColor=”FF0101″

Set the background color.

BannerView:gender=”M”

m, f

The user’s gender.

BannerView:keywordList=”Car, Racing, Game”

Keywords, describing the content. Comma separated.

BannerView:latitude=”37.787827″

Latitude of user’s location.

BannerView:longitude=” -122.406728″

Longitude of user’s location.

BannerView:locationUpdateEnabled=”true”

true, false

Enable transmission of location data.

BannerView:zip=”94108″

User’s zip code.

Using Toaster Style Banners

We are also offering a banner view which use a Toaster Style (Translate in screen when a banner is ready and off screen when the banner is clicked or the user dismiss it using a close button ), you can integrate the Toaster banner using

Where myRootRelativeLayout is the root relative layout in your activity. ToasterBanner implements also the same methods as BannerView. When you successfully load a new banner, as described in the BannerView section, the banner will automatically appear inside the screen.

disappearAndDestroy() Method (new)

disappearAndDestroy() method is to hide and destroy the ToasterBanner. This method internally calls disappear method and handles removing all childViews.

Example usage, invoke this method from onDestroy()

Using an Alert Banner

Alert banner is using the AlertDialog from Android, which will appear as an alert and containing an Ad. With the AlertBanner you can also use the same methods described for the BannerView. There is to types of alert view, the first one is the FullScreenBanner

FullScreenBanner mAlertBanner = new FullScreenBanner(context);

The second type is the AlertBanner, which will only request text ads, and will not contain a banner view, but a text ad, and an open and close button. Open button will open the default device browser and close button will simply dismiss the alert. In order to use this banner type, you need first to instantiate an object from AlertBanner. In your activity type the following line

AlertBanner mAlertBanner = new AlertBanner(context);

Please use the same methods described for BannerView in order to set your IDs, targeting options etc…

To fetch a new banner use

mAlertBanner.asyncLoadNewBanner();

You are also able to modify the alert title using

mAlertBanner.setTitle(“your title”);

Listener available

As the BannerView offers, with the AlertBanner you can also implement your AdListenerInterface (Please see description in BannerView)

In order to have more information about the alert banner states you can implement your AlertBannerStateListener using

you can change the debug level using (Please set the desired debug before instantiating any type of BannerViews)

Debugger.setDebugMode(Debugger.Level_1);

PS : You can find an Integration Sample for every single Banner Format in our Demo App, please import the project in your workspace and have a quick look to the integration code, you can see how it works.

Video Ads

Similar to interstitial ad units, video ads are shown in full screen mode and can be placed before, in between or after the app content. The video ad will be loaded in background, and will be waiting for a signal to show up.

First of all, the Video Player requires activity declaration in your AndroidManifest.xml as well:

Next, you will need to instantiate a Video object in the activity where you want to show video ads and to implement the VASTAdListener interface to have more control on the Video ads. Your IDE will ask you to implement following methods:

import com.smaato.soma.video.VASTAdListener;
public class MyActivity implements VASTAdListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myLayout);
Video videoAd = new Video(MyActivity.this);
}
// Called when the banner has been loaded.
public void onReadyToShow() {
// TODO
// Call this when you want to show the video ad.
videoAd.show();
}
// Called when the ad will show.
public void onWillShow() {
// TODO
}
// Called when the banner has been clicked.
public void onWillOpenLandingPage() {
// TODO
}
// Called when Interstitial ad will be close.
public void onWillClose() {
// TODO
}
// called when banner failed to load.
public void onFailedToLoadAd() {
// TODO
}
}

Of course, you will need to provide the SDK with your Smaato Publisher and AdSpace IDs, please use the following code for that:

Next, you will need to instantiate a Rewarded Video object in the activity where you want to show Rewarded Video ads and to implement the RewardedVideoListener interface to have more control on the Rewarded Video ads.

Native Ads

Native ads are designed in a way that respond exactly to your needs. With native ads, you're able to show ads in your apps that look completely the same as your app content. That means, more control for you, better design for your users, better user experience and of course more revenue for you!

Smaato Native Ads Serving Template (SNAST) gives you the flexibility to choose which elements you need for your ad space. Currently, we've got the following items available :

Ad Title

Ad Text

Icon Image (80x80 pixels)

Main Image (1200x627 pixels)

Click to install text (e.g. Install, Read More etc...)

Star rating (only for app ads)

In order to start using native ads, you will need to go through following steps :

Integrating other Templates (i.e. NativeLayout Types):

This implementation steps are similar for all other NativeLayout Types as well. Please bear in mind: NativeCarousel supports an ArrayList of ImageViews and accessible through nativeAd.getCarouselImages().

Send the required NativeType to the method nativeAd.asyncLoadNativeType.

The SmaatoDemoApp has sample implementations of all the NativeLayouts.

Using the Demo App

Within the SDK ZIP file, there's a demo app which shows an example of how to integrate our SDK, how to use it and how to implement desired options.