Windows Store App - Adding Advertising

posted on 14 Feb 2013 | Windows 8 App

I searched for hours trying to figure this out and I think the information is a little scarce or not obvious.

Basically I wanted to add some advertising to my app, I'm trying to cover multiple different area's in order to learn what's involved, and I thought I had it all down, only to work out that the advert's that were displaying were test adverts and not the real thing.

Now don't get me wrong, when you actually do find the correct URL (by searching Advertising rather than Ad) the MSDN link does have all the information, I didn't find this out until my friend actually sent it to me...

There's two main things you need to do (besides installing the correct SDK, I had the Beta first time around)

  1. Implement the advert into your app
  2. Setup an advertising account

The first part is easy... (well the 2nd part is too... but I didn't realise that at first)

Implementing your advert

Head on over to MSDN to download the Microsoft Advertising SDK and install it.

After installing, open up your solution and add a reference to the Microsoft Advertising SDK for Windows 8 (Xaml) assembly.

Now you can use the Tools to drag/drop the advert control to your Xaml file.

<ui:AdControl Name="Advert"
              ApplicationId="d25517cb-12d4-4699-8bdc-52040c712cab" />

The two things that are important are the AdUnitId and ApplicationId, the ApplicationId should get populated automatically using the test value. (the value shown in the code above) if not, you can manually assign it.

To test your advert you need to add a AdUnitId specific to the dimensions you want to show, and for the type of advert you want to test.

pubCenter Ad Unit Size (Width x Height) Experience AdUnitId
160 x 600 Windows 8 Image Ad with click to Full Screen Image 10043136
160 x 600 Windows 8 Video Ad with click to Full Screen Video 10043135
160 x 600 Windows 8 Image Ad 10043134

You can find a full list of test modes on MSDN - Test Mode Values

Find the Height/Width you want, ensure your Ad control is set to the same Height/Width, and assign the corresponding AdUnitId to the control.

Now when you run your app you should get something like

The next thing you need to do is add some error handling. To do this you just add the event to the control directly like ErrorOccurred="AdvertErrorOccurred"

void AdvertErrorOccurred(object sender, Microsoft.Advertising.WinRT.UI.AdErrorEventArgs e)
    Advert.Visibility = Visibility.Collapsed;

You may want to do something more, maybe try loading a different sized advert. I've chosen to just hide the control instead.

Setup an advertising account

Head on over to and login with your Windows Live account (or signup)

First you will need to head on over to the Accounts

Once you have created an account (you don't need to add a payout right away, you can do that in the future when you've generated some revenue), you need to head on over to Setup.

You need to Register your application, and then you need to create an AdUnit. This stuff is really straight forward so should be easy peasy.

Once you have registered your app (which gives you the ApplicationId) and created an AdUnit (which gives you the AdUnitId) you can replace the values in your app, and publish your app with advertising in it :D

Although this information is available on the net, I initially had trouble finding it, so hopefully this helps anyone else out with confusion.

comments powered by Disqus