Using the Windows Phone 7 Advertising SDK

Stopwatch Standard 4.4 Elapsed Time

Windows Phone Stopwatch 4.4 using the Windows Phone 7 Advertising SDK

While writing Windows Phone 7 applications is cool, writing Windows Phone 7 applications that earn money for you is really cool!

Why Monetize Windows Phone 7 Applications?

Microsoft Advertising has published two case studies that illustrate the earnings potential the Windows Phone platform has today, one detailing how two college students have grossed over $12,000 ad-revenue, the other details how a part-time developer is grossing over $7,000 a month in ad-revenue.

Microsoft Advertising:

Microsoft Advertising Case Studies:

According to Gartner and IDC the Windows Phone platform is expected to command a market share of 19.5% (Gartner) to 20.9% (IDC) in 2015. Analysts at Pyramid Research have said that they believe Windows Phone will beat Android and they say that Windows Phone will establish its leadership as early as 2013.

It’s useful to consider the overall market share that the Windows Phone platform will command in the coming years when deciding whether or not to monetize Windows Phone applications, just imagine how much ad-revenue the developers cited within the aforementioned case studies will be earning in the coming years.

See my earlier blog post: Why Windows Phone Will Beat Android.

Monetizing Windows Phone 7 Applications

With the Windows Phone 7 Advertising SDK installed you then have to reference the assembly, Microsoft.Advertising.Mobile.UI.dll, containing the AdControl class. You’ll find this assembly is installed within the following folder.

C:\Program Files (x86)\Microsoft Advertising SDK for Windows Phone 7

We’ll be discussing the use of the Advertising SDK within Silverlight applications although there is also another assembly installed by the Windows Phone 7 Advertising SDK for use within XNA based games and applications.

Using the following XAML the XML namespace for the Windows Phone 7 Advertising SDK is added to the PhoneApplicationPage definition. While the namespace alias advertising is used here you can use whatever namespace alias you choose.

<phone:PhoneApplicationPage
x:Class="Stopwatch.MainPage"
xmlns:advertising="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"
shell:SystemTray.IsVisible="True">

With the XML namespace defined we can now include the advertising user control within our Windows Phone 7 page using the following XAML.

<advertising:AdControl Height="80" Width="470"
HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="0,524,0,0" Name="adControl"
AdUnitId="10016992" ApplicationId="94e207a7-afda-4c65-a666-05bf001eebd4" />

You may have noticed the AdUnitId and ApplicationId properties within the above XAML declaration of the AdControl, these are unique to your account on the pubCenter website and it is through these two properties that Microsoft is able to track the impressions your application generates. It is these impressions that generate revenue and so you’ll want to ensure you enter the correct values for the AdUnitId and ApplicationId.

We’ll walk through the account creation process for the pubCenter website although first let’s complete the code required to integrate the Windows Phone 7 Advertising SDK into our application.

Open the MainPage.xaml.cs file and add the following using declaration.

using Microsoft.Advertising.Mobile.UI;

Within the constructor we need to disable the AdControl test mode as shown here.

/// <summary>
/// Initializes a new instance of the <see cref="T:MainPage"/> class.
/// </summary>
public MainPage()
{
InitializeComponent();

    AdControl.TestMode = false;
}

As an architect and a developer who has used the UML extensively for many years I always like to also explore a new SDK or class library by creating a class diagram such as the following class diagram of the AdControl class.

We can see that beyond the AdUnitId and ApplicationId properties discussed already, there are several other properties that you can use to tune advertising presented to the user assuming you have access to the required information.

AdControl

Let’s open a Web browser and navigate to https://pubcenter.microsoft.com and begin the process of signing up for an account and then we can come back with the values for the AdUnitId and ApplicationId properties.

PubCenter

Sign into the pubCenter website using a Windows Live ID, usually the same Windows Live ID that you use for the AppHub website. On the next screen, assuming you don’t already have an account on the pubCenter website, you can then choose to signup for a new pubCenter account. Let’s click Signup and continue.

PubCenter 2

Provide your name, email address, the country within which you reside, and language preferences.

PubCenter 3

We can now register an application and create an ad unit which will provide us the values for the AdUnitId and ApplicationId properties discussed earlier. With one pubCenter account you can create several applications and ad units so you can create additional applications and ad units later.

Provide a name for the application and ad unit and also specify the size of the ad unit or accept the default of 480x80 XX-Large banner.

PubCenter 4

You have control over the categories of advertisements that will be displayed on the application and so you should select the appropriate categories here. It is generally a good idea to choose categories that are either directly related to the application within which the advertising will be displayed or choose categories that are broadly applicable. In this example I have selected Sports although subcategories were not specified.

PubCenter 5

The pubCenter account has now been created and the newly generated Application ID and Ad Unit ID are listed for you to copy and paste into the code listing above.

PubCenter 6

Summary

We’ve seen how disruptive the Windows Phone platform is going to be over the next few years and that developers are making significant ad-revenue within their applications today.

See my earlier blog post Why Windows Phone Will Beat Android and the Microsoft Advertising case studies:

Also, visit the Microsoft Advertising website where you can find some great information (including case studies) about monetizing Windows Phone 7 applications.

We’ve also seen that with only a few lines of code your application will be earning ad-revenue and the potential growth of that ad-revenue is truly exciting. If you do monetize your Windows Phone applications you’ll likely be visiting the pubCenter website very often as the site provides some really cool reports and a dash board to help you track the generated ad-revenue.

As stated before, while writing Windows Phone 7 applications is cool, writing Windows Phone 7 applications that earn money for you is really cool!

I have personally incorporated advertising with the Windows Phone Stopwatch (see my earlier blog post Windows Phone Stopwatch 4.4 RTM) and will be incorporating advertising into another application to be released soon!