ad-mediation

Using Ad Mediation in Windows Phone 8 app

Ad mediation is an algorithm that enables your app to use multiple SDKs. This means that with the mediation code in place, your app will make a call to one ad control, and if that ad control cannot serve an ad, the app will then call a second ad control, then a third, and so on. The new ad mediation control provides a simple way to implement this capability in your apps. It offers several advantages over using a single ad network, giving you control to integrate multiple ad SDKs and optimize use based on performance. The highest revenue return can be achieved by choosing the ad network with highest eCPM first, then serving the unfilled ads from other ad networks. Here are some attractive features offered by Ad Mediation for Windows Phone

  • App level configuration
  • Global and optional market-specific configuration
  • Ad refresh rate
  • Pause/Resume ads
  • Ad network prioritization (e.g. specific network first, equal distribution, back-up only)
  • Ad network exclusion (do not use this ad network, globally or in a specific market)
  • Fill rate reporting by ad network and by market

Windows ad mediation capabilities are initially launching for Windows Phone 8.0, 8.1 Silverlight and 8.1 XAML. Currently you can use Microsoft Advertising, AdDuplex, Inneractive, Smaato, AdMob, InMobi and MobFox with Ad Mediation. You will need to set up an account on each of the ad providers that you plan to use and create an ad unit in it. Here are the steps to use Ad Mediation in your Windows Phone 8 app.

Step 1. Download and install the Windows Ad Mediator Extension

Before you can use Ad Mediator in your apps, you need to download and install Ad Mediator Extension. The Ad Mediation control will appear in the toolbox next time you open Visual Studio.

 

Step 2. Add the Ad Mediation control

From the Toolbox, drag a new AdMediatorControl into the designer. Position the control in the location where you’d like your ads to display. You can add multiple controls if you want to display ads in more than one area of your app. Be sure to drag the control into the designer, not into your XAML code. Code will be generated for the control, including a unique ID and a name for the control. Here is how it can be done in a Windows Phone 8 Silverlight application:

  The Name element will help you to identify the specific control in your app when you configure your ad mediation. You can change this to whatever you’d like, but be sure not to change or duplicate the Id element. This Id must be unique for each control within your app.

Step 3. Configure the controls

Once you’ve added all the controls you’d like, you’re ready to configure them through Connected Services. Note that if you add an additional AdMediatorControl later, you’ll need to configure it through Connected Services again. Otherwise, the new control will not be able to use ad mediation. To configure the controls, right-click the name of the project in Solution Explorer, click Add, and then click Connected Service… to launch the Services Manager window. By default, the Microsoft Advertising DLLs will be added, and Microsoft Advertising will be enabled. If you don’t want to use this ad network, you can remove it in the next step. For each of the selected ad networks, click on configure hyperlink to set the ad unit id for that ad provider. Even if you don’t configure the Ad Controls in the app, it can be done in the Windows Phone Developer Portal without needing to update the app again.

Step 4. Add or remove Ad Networks

To add and remove ad networks, click Select ad networks. You’ll see a list of all the ad networks that are supported for your project. Check the boxes of the ad networks you want to use. After you’ve selected your ad networks, click OK. The control will attempt to retrieve the DLLs for each ad network. You’ll see the progress and result of this process. Click OK, and you’ll be able to see which DLLs were successfully fetched.

Note: In some cases, you may see that certain DLLs were not fetched (for example AdMob as it is not available on Nuget). In this case, you’ll need to add them manually. For links to download individual assemblies, see Selecting and managing your ad networks.

 

Note

If you decide to add another ad network after doing this configuration, you’ll need to open the Services Manager window again, select the network, and ensure the DLLs are added.

Step 5. Add the required capabilities

Each ad network may require certain app capabilities. These are shown by each provider in the Services Manager window. Be sure to declare all of the required capabilities in your app’s manifest so that the ads are properly displayed.

Step 6. Handle unhandled exceptions from Ad Networks

As part of our testing, we’ve identified a number of unhandled exceptions from specific ad networks that must be handled within the app to avoid app crashes related to these exceptions. We highly recommend that you copy and paste the code sample below to your App.xaml.cs file. Code for Windows Phone 8 Silverlight application

Code for Windows Phone 8.1 XAML application

Step 7. Test the application

Running your app in the Windows Phone Emulator is a good first step. When you do so, test metadata will be used, so you can test your app and make sure it’s coded correctly before you’ve even entered your ad network required parameters. When you run your app in the emulator, the ad networks will rotate in sequential order, with one network displayed after another for equal amounts of time. Be sure to wait long enough to run through a few cycles so you can view all ad networks and reduce the chance of any temporary connectivity issues which may occur. Test ads will be displayed (for ad networks which support them).

 

Step 8. Submit the app and configure ad mediation

Once you’ve built your app to include all of the ad networks you may want to use, and tested it to ensure everything’s working, you’re ready to submit the app. During the submission process, you can configure the ad mediation behavior you’d like to see. You’ll be able to adjust this later without having to make code changes or submit new packages.
When you upload your packages, Dev Center automatically detects that you’re using ad mediation and identifies which ad networks you’re using. On the package upload page, you’ll see an Ad mediation configuration section. This is where you’ll configure your mediation logic. The first time you submit your app, you’ll create a baseline configuration. After that’s set up, you can add market-specific configurations to take advantage of specific ad networks’ strengths in different markets.

If you want to adjust your ad mediation for a specific app, you can do so at any time without having to resubmit the app. This is useful if you’ve already added ad networks into your app that you hadn’t previously set up accounts for, or if you’re finding that one ad network is not able to fill ads reliably in specific markets.

To make changes, view the app details page in Dev Center and click Ad mediation. You can make changes to your baseline configuration as well as to market-specific configurations. You can also add or remove market-specific configurations if desired.

You can download the project source code and use it as an reference.
Download full project Ad-Mediation-Demo.zip

Vivek Maskara

I am pursuing BTech in Software Engineering from Delhi Technological University. I develop apps, create websites and blog about my app experiences.

  • Soner

    My project is written in VB.Net and I have a serios problem for adding “Connected Service” to the project.
    Apparently that item does not exist in the context menu if the project language is VB.Net.
    I applied that step successfully in a C# project but VB?
    Does this mean you cannot add Connected Service to a VB.Net project?

    • Apparently, Microsoft doesn’t support Ad Mediation in VB.Net. Hope it changes soon..

      • Soner

        Interesting, not mentioned anywhere. ANyway, thanks for the article and answer.

        • georgebirbilis

          they’ve added such support now

  • Pingback: Using Ad Mediation in Windows Phone 8 app()

  • Vi Giang

    I have a problem when I drag a new AdMediatorControl into the designer. Please help me.

    • The problem maybe due to incompatibility of the AdMediator version. Try removing all references of Admediator from your project and reinstall the control using the visual studio gallery website. Also in the toolbox see ig you are using the correct version of the control. Your project is a WP8 Silverlight project so WP 8.1 XAML controls will be incompatible.

  • Alan

    Smaato ads are not properly aligned within the AdMediator control. There look to be about a 10 pixel margin on the left and on the top. This clips the ads displayed and does not look good. How can I fix this?

  • Azhar Yousuf

    Hey Vivek, I was just wondering if Ad Mediation works for Interstitial Ads too? any idea or did you use any network other than Admob to show interstitial in ad mediation?

  • I don’t know, but this is not working in my Windows Phone 8.1 silverlight apps. Util Step 2 everything is fine. but in step 3 right-click the name of the project in Solution Explorer, click Add, and
    then click Connected Service… to launch the Services Manager window. This service manager Window does not exist for me. I get this screen

    Any idea what’s wrong?

  • Garapani Venkatachalapathi

    Hi, how to integrate mobfox using windows ad mediator. it is not fetching the requires references in the project.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close