Monetizing App Studio with Ads

So, you’d like to put some ads in your awesome App Studio app? No problem! I thought I would write a post to show just how easy it can be. Follow these easy steps and you’ll start earning money from ads…

Ad provider

The ad provider is the service the AdControl in your app gets the ad to display and also where you earn the revenue. As of Windows Phone 8 there is a PubCenter AdControl built into the framework, all you need to do is get an ApplicationId and an AdUnitId. You get that information from Windows Phone DevCenter, find out how to get your ApplicationId and AdUnitId in this great blog post.

If you want to use a separate Ad provider, for example AdDuplex, you’ll need to add the provider’s DLLs to your project. I’m using AdDuplex in the example below, learn how to add AdDuplex to your project here.

Step One: Enable ads in App Studio

Before generating your App Studio app, you’ll want to enable ad support. On the Publish Info tab, turn on the Enable ad client in the source code switch (see #2 in this screenshot):

App Studio Screenshot

Next, generate the app and download the source code.

Step Two: Open App in Visual Studio

After downloading the source code, you might need to unblock the binaries before unzipping the folder. This is a built-in security feature that prevents internet-downloaded code from running on your machine. Since we know where these files came from, it’s ok to go and unblock them. Here is how to do that:

  1. Right click on the downloaded zip folder
  2. Select “Properties
  3. If you see an “Unblock” button, click it. If you do not, continue to step 4.
  4. Now you can safely unzip the folder

Next, drill down into the unzipped folder until you see the Visual Studio solution file. Double click to open it in Visual Studio (Note: You need Visual Studio installed. If you do not, you’ll need to download and install the Windows Phone SDK from here).

Step Three: AdControl on MainPage.xaml

Drill Down to MainPage.xaml, see this screenshot to help you find it:

Visual Studio Solution Explorer

Near the top of the page, you will see a commented out section of code (approximately line #50). This is the built-in AdControl. All you need to do is:

  1. Uncomment the AdControl (delete the <!– and –> characters before and after the AdControl)
  2. Replace the placeholder ApplicationId and AdUnitId with yours

In this screenshot, I demonstrate how to use an AdDuplex ad control instead of the built-in AdControl.

MainPage

That’s all there is to it! Now you can do a Build and publish the generated XAP file. (If you are not familiar with how to publish an app built with Visual Studio, see this documentation)

This image shows what the published app looks like running on a phone, see for yourself and download the app.

NetduinoNinjaScreenshot

Happy coding!

Lance

Here are some follow-up resources to help you monetize your apps:

10 thoughts on “Monetizing App Studio with Ads

  1. Barin IsWright says:

    Hey Lance: A great, to the point and detailed document!

    Question: Is there a way to see your ADs before your application is published? For example, when I make uncomment out the code and add my credentials. Can I build the application to my Windows8 phone and see the ADs?

    Thanks!
    Barin

    Reply
    1. Lance says:

      If you deploy the app (in release mode) to the emulator (or device) and you have your ad unit’s credentials correct, you should see the ad being served.

      Reply
      1. gobind neupane says:

        Hi Lance,
        Since, Microsoft ads are not working in all countries. How can I enable Pubcenter Ads and another third party Ads? So that when one Add is not working another Add will display instead of? I am working on windows phone 7 app and I am facing this trouble. Could you please help?

        Reply
        1. Lance says:

          You can use third party solutions to this, my favorite is AdRotator (you’ll want v2). It will automatically switch to the next ad provider when an ad fails. Ultimately if all ads fail, it will show a “house” ad so you can advertise your own apps.

          Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.