WinCoder Blog

Monetize your app with AdRotator for Windows 8 and Windows Phone

Have you published an app to the Windows Phone or Windows 8 store and are you looking to monetize it through advertising?  You may be very interested to learn about the AdRotator Nuget packages available for both Windows Phone and Windows 8.  AdRotator is essentially a component that allow for setting up multiple advertising publishers within your application.  The benefits of AdRotator include use of AdDuplex alongside Microsoft Pubcenter with your own house ad (and a host of other publishers, if you so choose).  Best of all, this can be set to be server side configurable to allow remote changes!  For example, you can specify in your remote configuration what percentage mix of ad providers to use dependent on country, and even show a default house ad in the event that no providers are available.  This opens up a whole host of advance configuration strategies that you can tailor to your analytics!  Imagine, I could crank up the probability of showing AdDuplex ads in my initial marketing phase and then increase my payment-driven providers like Pubcenter when I reach a high enough threshold of users all through remote configuration changes during the lifetime of my application.  I could even run my own promos using the house ad mechanism to showcase another app of mine or invite users to follow my apps Facebook fan page!  Best of all, in the case that one of my providers fails to show an ad, the control will automatically fall back to the provider with the highest probability of serving my ad that is capable of doing so.

Getting started is as easy as adding the respective Nuget package to your project.

You can do this by right-clicking the references folder of your Win8 or WinPhone project and selecting “Manage Nuget Packages”.

Next, do a search of online packages for “AdRotator” and click the Install button for your platform
OR
on the Package Manage Console simply enter: 
Install-Package AdRotatorWin8″
Install-Package AdRotatorWP”
Depending on your desired platform.
Regardless of platform, a .xml will be added to your root directory called “defaultAdSettings.xml”.  These are the setting for the AdRotator control that will be loaded in the event that no remote settings are supplied or found.  Here is an example showing a config using PubCenter in combination with AdDuplex.  Note that for each country I can set a property of CultureName (taken from the Table of Language Culture Names, Codes, and ISO Values).  Followed by a Probability (the sum of all must equal 100), AdType, and my AppID (found on Pubcenter and AdDuplex site).  
For the first AdCultureDescriptor, this can be read as: If a user is identified as English United States, show an ad from Pubcenter with a probability of 80%, show an ad from AdDuplex with a probability of 15%, and show my DefaultHouseAd with a probability of 5%.  
Notice that Pubcenter uses a 32 digit GUID, AdDuplex a 5 digit Id, and DefaultHouseAd a remote Url for it’s AppID value.  Once you have your defaultAdSettings defined, you can upload them to a remote Url where you can then make server side configuration changes provided you set up your control to use a “SettingsUrl” (described further down).
Here are my defaultAdSettings for Windows8:
xml version="1.0" encoding="utf-8"?>
<AdSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <CultureDescriptors>
 <AdCultureDescriptor CultureName="en-US">
      <Probabilities Probability="80" AdType="PubCenter" AppID="def34cbe-ba4b-4b90-a987-9dae46fd7168" SecondaryID="10052001" />
      <Probabilities Probability="15" AdType="AdDuplex" AppID="27183"/>
      <Probabilities Probability="5" AdType="DefaultHouseAd" AppID="http://searchler.com/AdRotator/MyDefaultAdWin8.xaml"/>
    AdCultureDescriptor>
 <AdCultureDescriptor CultureName="en-GB"
      <Probabilities Probability="80" AdType="PubCenter" AppID="def34cbe-ba4b-4b90-a987-9dae46fd7168" SecondaryID="10052001" />
      <Probabilities Probability="15" AdType="AdDuplex" AppID="27183"/>
      <Probabilities Probability="5" AdType="DefaultHouseAd" AppID="http://searchler.com/AdRotator/MyDefaultAdWin8.xaml"/>
    AdCultureDescriptor>
 <AdCultureDescriptor CultureName="de-DE">
      <Probabilities Probability="75" AdType="PubCenter" AppID="def34cbe-ba4b-4b90-a987-9dae46fd7168" SecondaryID="10052001" />
      <Probabilities Probability="20" AdType="AdDuplex" AppID="27183"/>
      <Probabilities Probability="5" AdType="DefaultHouseAd" AppID="http://searchler.com/AdRotator/MyDefaultAdWin8.xaml"/>
    AdCultureDescriptor>
 <AdCultureDescriptor CultureName="default">
      <Probabilities Probability="80" AdType="PubCenter" AppID="def34cbe-ba4b-4b90-a987-9dae46fd7168" SecondaryID="10052001" />
      <Probabilities Probability="15" AdType="AdDuplex" AppID="27183"/>
      <Probabilities Probability="5" AdType="DefaultHouseAd" AppID="http://searchler.com/AdRotator/MyDefaultAdWin8.xaml"/>
    AdCultureDescriptor>
 CultureDescriptors>
AdSettings>

Here are my defaultAdSettings for WindowsPhone:
(Note:MobFox and AdMob use the Ad Id obtained from their respective platform config portal)
xml version="1.0" encoding="utf-8"?>
<AdSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <CultureDescriptors>
    <AdCultureDescriptor CultureName="en-US">
      
      <Probabilities Probability="0" AdType="MobFox" AppID="a21220fa133b775733ae90a9d34e9aa4>" IsTest="false"/>
      <Probabilities Probability="0" AdType="AdMob" AppID="a150139f224badb"/>-->
      <Probabilities Probability="80" AdType="PubCenter" AppID="b6233820-1003-4063-a96b-d09042840fd8>" SecondaryID="10040909" />
      <Probabilities Probability="10" AdType="AdDuplex" AppID="16999"/>
      <Probabilities Probability="10" AdType="DefaultHouseAd" AppID="http://searchler.com/AdRotator/MyDefaultAd.xaml"/>
    AdCultureDescriptor>
    <AdCultureDescriptor CultureName="en-GB">
      
      <Probabilities Probability="0" AdType="MobFox" AppID="a21220fa133b775733ae90a9d34e9aa4>" IsTest="false"/>
      <Probabilities Probability="80" AdType="PubCenter" AppID="b6233820-1003-4063-a96b-d09042840fd8>" SecondaryID="10040909" />
      <Probabilities Probability="15" AdType="AdDuplex" AppID="16999"/>
      <Probabilities Probability="5" AdType="DefaultHouseAd" AppID="http://searchler.com/AdRotator/MyDefaultAd.xaml"/>
    AdCultureDescriptor>
    <AdCultureDescriptor CultureName="de-DE">
      
      <Probabilities Probability="0" AdType="MobFox" AppID="a21220fa133b775733ae90a9d34e9aa4>" IsTest="false"/>
      <Probabilities Probability="75" AdType="PubCenter" AppID="b6233820-1003-4063-a96b-d09042840fd8>" SecondaryID="10040909" />
      <Probabilities Probability="20" AdType="AdDuplex" AppID="16999"/>
      <Probabilities Probability="5" AdType="DefaultHouseAd" AppID="http://searchler.com/AdRotator/MyDefaultAd.xaml"/>
    AdCultureDescriptor>
    <AdCultureDescriptor CultureName="default">
      
      <Probabilities Probability="0" AdType="MobFox" AppID="a21220fa133b775733ae90a9d34e9aa4>" IsTest="false"/>
      <Probabilities Probability="75" AdType="PubCenter" AppID="b6233820-1003-4063-a96b-d09042840fd8>" SecondaryID="10040909" />
      <Probabilities Probability="10" AdType="AdDuplex" AppID="16999"/>
      <Probabilities Probability="5" AdType="AdMob" AppID="a150139f224badb"/>
      
      <Probabilities Probability="10" AdType="DefaultHouseAd" AppID="http://searchler.com/AdRotator/MyDefaultAd.xaml"/>
    AdCultureDescriptor>
  CultureDescriptors
AdSettings>:
Here is what my DefaultHouseAd looks like for Windows 8:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">

  <Grid x:Name="LayoutRoot">
    <HyperlinkButton
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            NavigateUri="http://www.windowsphone.com/en-us/store/app/searchler-music-video-search/aa7b0980-cfd7-4533-8b9c-6c54d542c5cf"
     >

      <HyperlinkButton.Background>
        <ImageBrush ImageSource="http://searchler.com/AdRotator/Assets/SearchlerPhoneAd.png"/>
      HyperlinkButton.Background>

    HyperlinkButton>

  Grid>
UserControl>
Here is what my DefaultHouseAd looks like for Windows Phone:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">

  <Grid x:Name="LayoutRoot">
    <HyperlinkButton
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            NavigateUri="http://www.facebook.com/Searchler"
            TargetName="_blank"
     >

      <HyperlinkButton.Background>
        <ImageBrush ImageSource="http://searchler.com/AdRotator/Assets/SearchlerFacebook.png"/>
      HyperlinkButton.Background>

    HyperlinkButton>

  Grid>
UserControl>
To add your control in Windows 8 use xaml similar to the following.  Height and Width will depend on the desired size you have set in your Ad Providers, SettingsUrl will point to your remotely hosted settings file (you can disregard this if you wish to use baked-in defaultAdSettings.xml):
        
<AdRotator:AdRotatorControl
            x:Name="adControlLarge"
            AdHeight="90"
            AdWidth="728"
            DefaultSettingsFileUri="defaultAdSettings.xml"
            SettingsUrl="http://mydomain.com/remoteSettings.xml" 
            Width="728" Height="90"/>

Similarly, to add your control in Windows Phone use xaml similar to the following. Height and Width will depend on the desired size you have set in your Ad Providers, SettingsUrl will point to your remotely hosted settings file (you can disregard this if you wish to use baked-in defaultAdSettings.xml):

            <adRotator:AdRotatorControl 
            xmlns:adRotator="clr-namespace:AdRotator;assembly=AdRotator"
            x:Name="AdRotatorControl"
            Width="480" Height="80"
                SettingsUrl="http://searchler.com/AdRotator/myAdSettings.xml"
                DefaultAdType="PubCenter"
                DefaultSettingsFileUri="/AppAssemblyName;component/defaultAdSettings.xml"
                PubCenterAdUnitId="10040909"
                PubCenterAppId="b6233820-1003-4063-a96b-d09042840fd8"
                AdDuplexAppId="16999"
                AdMobAdUnitId="a150139f224badb"
                MobFoxAppId="a21220fa133b775733ae90a9d34e9aa4"/>

4 comments for “Monetize your app with AdRotator for Windows 8 and Windows Phone

Leave a Reply

Your email address will not be published. Required fields are marked *