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

Integrating Vserv ads in Windows Phone 8 app

Vserv’s new WP8 SDK offers offers a great opportunity to monetize your apps or games with only a small amount of additional effort. The Vserv.mobi WP8 SDK is designed to help you integrate Vserv Ads in your application and fast track your way to monetizing your WP8 applications.

Step 1. Register an account on vserv.mobi

If you already have a developer account at verv then skip to next step otherwise visit the following link to create a new account.

http://www.vserv.mobi/get-started/?at=developer

 

 

Step 2. Get your Zone ID from verv dashboard

Note down your ZoneID. This will be required later on when you use the WP8 SDK to request Ads. The default ZoneID will be available in your welcome email or you could visit https://admin.vserv.mobi/admin/affiliate-zones.php to get a list of all your zones.

 

 

Step 3. Get the vserv SDK for Windows Phone 8

Method I

The first step to integrating Vserv SDK in your WP8 application is to download our SDK package. The SDK package is available at the following link

http://www.vserv.mobi/sdk/WindowsPhone/VservWP8SDK.zip

We suggest that you unzip the SDK Zip file that you just downloaded into a temporary folder. You would find two folders in it, WP8V2SDK and SampleApp.

  • Add a reference to vservWindowsPhone.dll to your project (Refer to this article if you get struck in adding a reference)
  • Add the Images folder to your project from the vserv SDK folder

Method II

Alternatively the SDK can also be downloaded as NuGet package using the following command in the Nuget package manager (Refer to this article if you get struck in adding a reference).

Install-Package mobi.vserv.ads

Step 4. Add the following capabilities in your project

You also need to make sure that your project has the following capabilities

  • ID_CAP_NETWORKING”
  • ID_CAP_MEDIALIB_AUDIO”
  • ID_CAP_MEDIALIB_PLAYBACK”
  • ID_CAP_WEBBROWSERCOMPONENT”
  • ID_CAP_IDENTITY_DEVICE”
  • ID_CAP_IDENTITY_USER”
  • ID_CAP_PHONEDIALER
  • ID_CAP_REMOVABLE_STORAGE

 

 

Step 5. Requesting vserv ads

Using vserv SDK you can either have banner ads or full page interstitial ads in your application. Before you request for Ads you need to make sure you initialize the VservAdControl. Ideally you should initialize this when defining it in your project before the calling constructor.

VservAdControl VMB = VservAdControl.Instance;

Interstitial ads

To request an interstitial you need to call the displayAd() method.

VMB.DisplayAd(zoneID, LayoutRoot);

Note:

  • displayAd() is a part of the VservAdControl (vservWindowsPhone library) which need to be initialized before requesting for an Ad.
  • Optionally you can also set a timeout using the SetRequestTimeOut (timeout) method.
  • Make sure you pass LayoutRoot, else the full-screen ad will be displayed in the small banner.

Banner ads

You can request for Banner Ads which auto refresh automatically in a specific View using RenderAd() method.

Firstly, add an AdGrid in your MainPage.xaml file

<Grid Name=”AdGrid1″></Grid>

Then in the LayoutRoot loaded event handler add the code to render banner ads in your AdGrid1

Note: The RenderAd function takes two parameters

  • First is the zoneID which you copied from your dashboard earlier
  • Second is the name of the grid in which you wish to display ads

Callback functions

 

No Fill Callback

Sometimes vserv fails to deliver an ad. You would need to remove or hide the Banner Control when working with Banner Ads and other ad networks in its place.

void VACCallback_OnVservAdNoFill(object sender, EventArgs e)

Network Error Callback

At times when you request for an ad, there might not be any network available during the request, in which case the Vserv SDK calls the following method.

void VACCallback_OnVservAdNetworkError(object sender, EventArgs e)

Ad Close Callback

This is an essential callback which you need to implement. The Vserv Ads make use of the ApplicationBar to provide a native experience to the user, this is achieved by taking over your ApplicationBar. Thus, ideally you need to reinitialize your ApplicationBar in this callback. This is called when the user returns to your App from the Ad

void VACCallback_OnVservAdClosing(object sender, EventArgs e)

Get the full project source code here,

Download full project source code Vserv-ads.zip

Adding Microsoft pubcenter ads in Windows Phone 8 apps

Recently lots of developers are seen facing problems with pubcenter ads. The impressions are at an all-time low still for some developers ads never show up (not even the test ads). There’s a little thing that developers should be mindful of and pubcenter will again start working for them. Heres a tutorial explaining how you could integrate pubcenter advertisements in your Windows Phone 8 apps.

Step 1. Visit pubcenter website and add a new application in it

Visit pubcenter website to create a new application and its ad unit

https://pubcenter.microsoft.com/

 

 

Note down the application ID and the ad unit ID which you just created.

Step 2. Add a reference to Microsoft.Advertising.Mobile.UI

Right click on the name of the project in solution explorer and choose Add>Reference. From the dialog box that appears choose Microsoft.Advertising.Mobile.UI and Microsoft.Advertising.Mobile and add it to your project. These references will enable you to use Microsoft’s pubcenter ads in your app. Instead of adding the reference you could have dragged and dropped the AdControl from Toolbox.

 


 

Step 3. Crucial step- Add the following capabilities carefully

Not adding all the required capabilities is main reason behind ads not showing up from pubcenter. Not choosing the right capabilities doesn’t lead to a syntax error and no error is reported while deploying the app. The following ID_CAP capabilities must be included in the manifest of the advertising-enabled app.

  • ID_CAP_IDENTITY_USER
  • ID_CAP_MEDIALIB_PHOTO
  • ID_CAP_NETWORKING
  • ID_CAP_PHONEDIALER
  • ID_CAP_WEBBROWSERCOMPONENT

Go to Solution Explorer> Properties> WMAPPManifest.xml and move over to capabilities tab. From there choose the following capabilities. You may require other capabilities based on the type of application you are building but these will be required for pubcenter.

 

Step 4. Add a reference to the page where you want to display ads

Add the following reference to the page where you wish to display ads from pubcenter.

xmlns:UI=”clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI”

 

Step 5. Add the AdControl to your page

Add the AdControl to your page and insert the app id and ad unit id in it. If you are unsure where to put the code then have a look at the screen shot below. Also notice that the app id and ad unit id are set to test_client and Image480_80 respectively which is the default value. Also we have added an error occurred event handler.

Note: While debugging the app on emulator ads won’t show up if you are using a real app id and ad unit id. Instead if you use test values then a default ad will be visible    

Step 6. Add the error occurred event handler in code behind

You could use this event handler while debugging to know the reason for ads not appearing in the app. Most of the times if the ad control is correctly configured the reason for ads not appearing is low fill rates. Also you could use this event handler to load ads from another provider if ads from pubcenter fails. The code snippet show how you could add Google Admob’s ads when pubcenter fails to get an ad.

Here’s an article explaining how you could add Google AdMob in your Windows Phone 8 app.

 

Note

A few users have claimed that they can’t find this event trigger in their ad control. They might not be using the latest Ad SDK.

When you run the app in the emulator ads should now appear. Here’s a screenshot of the sample app i built.

Capture

 

Get the full source code of the app here,

Download full project source code pubcenter.zip

How to use Google AdMob in Windows Phone app

When it comes to monetization using in-app advertisements in Windows Phone apps, there are quite a few option like Microsoft’s Pubcenter, Mobfox, Smaato, AdDuplex, Nokia’s Inneractive and Google’s Admob. In the past two years I have tried all these ad providers and have finally struck to Google’s Admob. There was a period when Microsoft’s Pubcenter gave the best returns but gradually its fill rates started dropping and earnings dropped by around 99.5% for developers outside US. That made me try other ad providers available for WP and frankly none of them are as good as Pubcenter(the old one) but now developers don’t have a choice. In this post I will show you how you can integrate AdMob in your Windows Phone app. You can add AdMob in your app by XAML or via code in C#.

UPDATE:

We have noticed a improved eCPM(0.2 $ to 1.1$) and fill rates(60% to 90%) for pubcenter. So you might consider using pubcenter in your windows phone app.

If you have significant traffic in India then you can give a try to Vserv for Windows Phone 8 which gives a better eCPM than AdMob.

 

Step 1. Getting the SDK

Firstly download Google Admob SDK for Windows Phone from the link below

https://developers.google.com/mobile-ads-sdk/

 

Step 2. Creating an ad unit 

Go to your AdMob account and create an ad unit for your app

https://apps.admob.com/#home

Note: You would need a upgraded Admob account for this purpose and the previous admob account is no longer supported. You can read more about it here.

 

Fill in the details to create an AdUnit as follows

  • Fill in your app name and select platform

  • You can configure analytics for your app and link it to your Google analytics account. Learn how to integrate Google analytics in your app. We will skip it for now.
  • Select the type of AdUnit and fill in the name for the AdUnit. You can customize the look of the ad whenever you want
  • Click on save and an AdUnit id would be generated.

 

 

All done you are ready setting thing up for AdMob.

 

Step 3. Add the GoogleAds reference to your project

Unzip the SDK files and you will find a GoogleAds.dll file in it. Create a new project and add a reference to this dll file in your project. Here’s an article explaining how to integrate a Toolkit or Third party SDK with windows phone app using NuGet Package Manager.

 

Note

If the GoogleAds.dll is showing as incompatible then follow these steps

  • In the file explorer, navigate to the Google Ads.dll
  • Right click the dll file and click ‘Properties’
  • In the ‘General’ tab, at the bottom, there will be an ‘unblock’ button
  • Unblock the dll file and add it again in your project

 

IMPORTANT: You will need to add the following capabilities in your app for ads to appear!

  • ID_CAP_NETWORKING: Access to network services is required when requesting ads.
  • ID_CAP_WEBBROWSERCOMPONENT: Required since the AdView is a web browser.
  • ID_CAP_MEDIALIB_PLAYBACK: Provides access for currently playing media items.
  • ID_CAP_MEDIALIB_AUDIO: Provides read access to audio items in media library.

 

Now you can either add ads using XAML or via C#

How to add ads using XAML

 

Go to Toolbox in your Visual Studio and right click on general category and select Choose Items.

 

 

From the choose items dialog box tick AdView from Google Ads and click OK to include the control in the Toolbox.

 

 

Now you can view AdView control in the Common Controls list of the Toolbox. Select and drag it to place it anywhere in the page

 

 

Add the AdUnit ID you generated earlier to the control. The XAML should now look similar to this.
  If you have added the XAML code directly then a reference will be required for AdView control   xmlns:GoogleAds="clr-namespace:GoogleAds;assembly=GoogleAds"  

How to add ads using C#

  • Add the code below to display ads using C#
  • You can see the function admob(StackPanel stck ) takes a parameter which is the name of the stackpanel in which you wish to place your ad. Instead of a stackpanel you could use a Grid too.
  • Add the StackPanel in which you wish to place your ad in the XAML
  • Call the admob function in the page constructor as follows
    admob(AdGrid);
  • The advantage of this procedure is that you could place multiple ads in different StackPanels or Grid just by changing the name of the StackPanel/Grid in the parameter

 

Here is how the app looks when you run it in the emulator.

 

 

Download full project Google Admob.zip