Add Ads to your App

Why ads to begin with?

I have a few apps in the Marketplace that can be purchased. The average end user though is not going to purchase anything that they haven’t tested. Therefore it makes sense to have a trial version of the app. The trial version usually has some limitations. Either you limit the functionality of the app, or, like I am doing in my apps, the trial version is ad-driven.

To add ads to your Windows Phone App you just need to follow a few steps.

1. Make sure you have the latest tools. You can find them here.

Although that ships with the Advertising SDK, it is recommended to download the latest version of the Advertising SDK as well.

2. Add a Reference:

Since I am developing my apps in Silverlight, this is the one I need.

3. In the root element of my XAML file I need to add this:

In the Layout root of my XAML file I create my AdControl:

Of all the properties of the AdControl, ApplicationId and AdUnitId are the most critical. The example uses special values intended for testing. Let’s see how that looks:

Even though the SDK lists several different sizes for supported ads, only two have test images, that you specify through the AdUnitId property. For a 480×80 image, I use Image480_80 and for a 300×50 image, I use Image300_50. For a Windows Phone application it is recommended to use a 480×80 image.

One more property that is important to know is the RotationEnabled property, which by default is set to true. This means that a new ad will periodically and automatically be shown.

4. Get ApplicationId and AdUnitId at the Microsoft Advertising pubCenter. For every application you have ads for, you need to get an application ID. Each application can have multiple ad Units. If you are visiting the pubCenter for the first time, click the ‘Get Started’ button, otherwise sign in.

At the top there are two rows of tabs. First click the ‘Setup’ tab in the first row, and then ‘Sites and Apps’ in the second row. Click ‘Create a new application’:

Now you need to specify a name for your application. With clicking “add”, the Application ID will be assigned.

Once you have that, you can click on ‘Ad Units’ in the second tabs row. Click on ‘Create a new Application Ad Unit’. Now you need to select up to three categories per Ad Unit. This specifies the kinds of ads you want to be shown in your application

5. Now you need to set the assigned values to the ApplicationId and AdUnitId properties of your AdControl.

In order to get real ads, you need to set the static TestMode property to false in the constructor:

Here you can find more information.


To be continued…




  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: