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

Using AdDuplex in Universal Windows Apps

AdDuplex offers an universal app SDK in addition to its existing SDK for Windows Phone 7.8 and Windows Phone 8. This universal app SDK can be used with either universal Windows apps or standalone Windows 8.1 or Windows Phone 8.1 XAML apps.

Step 1. Register for a publisher account on AdDuplex

First thing first. If you don’t have an adduplex account, register on

http://www.adduplex.com


 

Step 2. Register a new app from your dashboard

Click on New App button in the dashboard to register a new app. We are building a Universal app which will run on both Windows Phone 8.1 and Windows 8.1. So we will need to register two new apps here, one for phone and other for desktop.

 


 

Enter the details for the app and choose an appropriate platform.

 

Once you create the app, note down the App ID which we will need while developing the application.

 

Step 3. Create a new Universal App project

The SDK can be used for either an universal app or standalone Windows 8.1 or Windows Phone 8.1 XAML apps. So in your Visual Studio Choose a Blank Universal app from the installed templates.

 

 

Step 4. Download the SDK from Visual Studio Gallery website

You can get the SDK from Visual Studio Gallery’s website. I am not sure if its available on Nuget too.

http://visualstudiogallery.msdn.microsoft.com/92f919ee-40a8-4549-8768-d3b453ceebea


 

Adding AdDuplex to Windows 8.1 app

 

Step 5. Add a Reference to AdDuplex SDK for Windows 8.1

In your Windows 8.1 project add a reference to AdDuplex SDK for Windows 8.1. From the Solution Explorer window, right click References…, and select Add New Reference…

 

Step 6. Add the namespace for AdDuplex in MainPage.xaml

Next, add a namespace for adduplex on the page where you wish to display ads.


 

Step 7. Add the AdDuplex adcontrol in your page

Finally add the code for adduplex’s AdControl in your page. Use the app id which you generated earlier while registering the app on adduplex’s website.

Note: Make sure the whole AdControl is visible by verifying that it’s not obstructed by any other objects on your page. We recommend setting the Canvas.ZIndex property to a high value to make sure the AdControl is not being covered.

 


 

That’s it. You can run the Windows 8.1 app on the local machine and hopefully an ad will appear.


 

Adding AdDuplex to Windows Phone 8.1 XAML App

 

Step 8. Add a reference to Windows Phone 8.1 XAML SDK

Similar to the Windows 8.1 app, you need to add a reference to AdDuplex SDK for Windows Phone 8.1(XAML) in your project for Windows Phone 8.1


 

Step 9. Add the namespace and adcontrol for AdDuplex in MainPage.xaml

Just like the Windows 8.1 app add the namespace and adcontrol to your page. Use the app id which you generated earlier while registering the app on adduplex’s website.


 

That’s it. You can run the Windows Phone 8.1 app on the emulator and hopefully an ad will appear.


 

Download full project AdDuplex-Ads.zip

Using AdDuplex for Windows Phone 8 Silverlight app

AdDuplex is a cross-promotion network specifically targeted at Windows 8 and Windows Phone apps and games. You add our AdControl to your application and start serving ads for other apps. They serve ads for your app in return. The ratio is 8:10. This means for each 10 ads displayed in your app 8 of your ads will be displayed in other apps. The remaining 2 ads will be sold to support the service. The advantage of using adduplex is that it has a 100% fill rate. So it is often used as a secondary option to fill ad space if the primary ad network fails to deliver an ad.

You may consider using these as your primary ad networks

Here’s how you could use AdDuplex in your app.

Step 1. Register for a publisher account on AdDuplex

First thing first. If you don’t have an adduplex account, register on

http://www.adduplex.com


 

Step 2. Register a new app from your dashboard

Click on New App button in the dashboard to register a new app. We are building a Windows Phone 8 Silverlight application.


 

Enter the details for the app and choose an appropriate platform.

 

Once you create the app, note down the App ID which we will need while developing the application.

 

Step 3. Create a new Windows Phone 8 Silverlight app

Choose a Blank Windows Phone Silverlight template from installed templates and create a project.

 


 

Step 4. Add AdDuplex SDK to your project using Nuget

Next, add AdDuplex SDK to your project using Nuget package installer. You might want to see

How to integrate a Toolkit or Third party SDK with windows phone app using NuGet Package Manager

 


 

Step 5. Add the namespace for using AdDuplex in MainPage.xaml

Add the namespace for AdDuplex on pages where you wish to display ads

xmlns:adduplex=”clr-namespace:AdDuplex;assembly=AdDuplex.WindowsPhone”

Step 6. Add the adcontrol in your page

Now add the adcontrol in your page. Use the App id which you generated earlier.


 

Note:

  • You can preview your own exchange ad by setting IsTest property to true.
  • Make sure the whole AdControl is visible by verifying that it’s not obstructed by any other objects on your page.

Download full project AdDuplex-Example.zip