Using Microsoft Advertising SDK in Windows Store Apps – Boredom Challenge Day 18


The main reason for developing software is, of course, earning money. 🙂 For desktop applications, the most common way of monetization is directly purchasing a license – the user pays a specific sum and gets to use the software. In the case of mobile development however, apps need to be very addictive or very useful, and overall need a lot of effort put into them to be successfully sold directly for a price. Another aspect of mobile apps is that paying for applications is usually a new (and alien) concept for many mobile users, and you can guess that they don’t like it much (I’ve seen many cases where a user gives bad ratings to a quite good game priced at a few dollars, just because it wasn’t free).

Click the image and view it in full size. You'll see that nearly all of the top "paid" apps are games, and they require a lot of effort to develop.

Click the image and view it in full size. You’ll see that “paid” apps require a lot of work to be successful (most of them are games, too).

This situation has resulted in alternative monetization techniques for mobile apps. One of them was adding trial versions which gave the users a taste of the app, and told them to buy it if they liked it. Another was to make the app free but to add in-app purchases such as removing limits or adding new items, characters or levels. And the final one was to put ads to gain revenue, either by making the app free and using ads as the main funding source, or making two versions of the app (a free version with (usually annoying) ads and a paid version without them).

In this article, we’ll see how we can go with using ads, and we’ll create an example Windows Store app that uses them. For this purpose, we have Microsoft Advertising SDK (for Windows Phone and Windows 8), that makes it very easy for us to include ads in our apps (with nice features such as using location to show more relevant ads). Now, I haven’t seen anyone who likes ads, but they are actually quite effective if used correctly, especially if your app has a high usage value (that is, if users would not just open your app once and don’t touch it ever again). This way, you can actually have a slow and steady income.

We will start by registering to Microsoft Advertising pubCenter. Go to, click Sign Up and login with your Microsoft Account.


Then fill in your information and click Continue.


In the next page, don’t add an application or ad unit yet and just go on to the overview page.


Here, we can create applications, and ad units to show in those applications. We can also use global exclusion list to exclude certain domains from showing their ads, which can be useful if you have rivals and don’t want to show ads belonging to them. Now we’ll create an app for our example by clicking Register application.



The application id we see here will be used in our app to show the ads. Now we’ll just need to create an ad unit, by clicking “Create ad unit” under Windows 8 application ad units.



The size of the ad unit defines the style of the ad returned, so you can create an ad unit which fits the design of your app. The ad unit id here will also be used when we want to show the ads.

Our work on pubCenter is complete, however, one last thing you may want to do is to go under the Accounts tab and add a payment method. 🙂

Now, download and install Microsoft Advertising SDK for Windows 8 (or for Windows 8.1 which comes with Visual Studio 2013). I’ll be using Windows 8 version for this article. After it is installed, open up Visual Studio and create a new blank Windows Store app project.


Then right click References in Solution Explorer, select “Add Reference” and then add Microsoft Advertising SDK under Windows -> Extensions.


Finally, we’ll add the AdControl to the MainPage.xaml. You can directly drag and drop it to MainPage.xaml from the Toolbox (if it is not shown in the Toolbox, right click and select Show All).


<Page xmlns:UI="using:Microsoft.Advertising.WinRT.UI"

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <UI:AdControl x:Name="AdControlMainPage" Width="300" Height="250" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,100"
        <TextBlock HorizontalAlignment="Center" Margin="0,190,0,0" TextWrapping="Wrap" Text="Please click the ad, I need moniez. :⁢(" VerticalAlignment="Center" FontSize="15"/>

That’s just it. If you run the app, you may see the ad. I’m saying *you may see* because first, live ads don’t work in the emulator, and second, there may not be an ad available right away. To fix this, you can use the application id and ad unit id’s from this link to test how the ad looks (just don’t forget to change them back to your own ids).


If you wish, you can use AdControl’s ErrorOccurred event to check when an error occurs (including if there are no ads to display) or you can set the Latitude and Longitude of the AdControl for regional ads (setting this in codebehind would be a better way since you can determine the current user’s location). You can also set IsAutoRefreshEnabled property to false, and choose when to refresh the ads yourself by calling AdControl.Refresh().

That’s it. Just remember not to go overboard with ads, otherwise they will not be very effective and won’t make you gain much money. 🙂

Here‘s the source code of the example app.

Thank you for reading.



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