Set up ad units in your app

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

Every banner ad or interstitial ad in your app has a corresponding ad unit that is used by our services to serve ads to the control. Each ad unit consists of an ad unit ID and application ID that you must assign to the AdControl or InterstitialAd in your app.

We provide test ad unit values that you can use during testing to confirm that your app shows test ads. These test values can only be used in a test version of your app. If you try to use test values in your app after you publish it, your live app not receive ads.

After you finish testing your UWP app and you are ready to submit it to Windows Dev Center, you must create a live ad unit from the Monetize with ads page in the Windows Dev Center dashboard and update your app code to use the application ID and ad unit ID values for this ad unit.

Test ad units

While you are developing your app, use the test application ID and ad unit ID values from this section to see how your app renders ads during testing.

  • Ad unit id: test
  • Ad unit id: 3f83fe91-d6be-434d-a0ae-7351c5a997f1

Note  For an AdControl, the size of a live ad is defined by the Width and Height properties. For best results, make sure that the Width and Height properties in your code are one of the supported ad sizes for banner ads. The Width and Height properties will not change based on the size of a live ad.

 

Interstitial ads

  • Ad unit id: test
  • Ad unit id: d25517cb-12d4-4699-8bdc-52040c712cab

Live ad units

To get a live ad unit from the Dev Center dashboard and use it in your app:

  1. On the Windows Dev Center dashboard, select your app and then click Monetization > Monetize with ads.
  2. In the Create ad units section, enter a name for the ad unit in the Ad unit name field.
  3. In the Ad unit type drop-down, select the type of ad unit that corresponds to the ads you are showing in your control:
    • If you are using an AdControl in your app to show banner ads, select Banner.
    • If you are using an InterstitialAd in your app to show video interstitial ads, select Video interstitial.
  4. In the Device family drop-down, select PC/Tablet (Windows 8.1) or Mobile (Windows Phone 8.x).
  5. Click Create ad unit. The new ad unit appears at the top of the list in the Available ad units section on this page.
  6. For each generated ad unit, you will see an Application ID and an Ad unit ID. To show ads in your app, you'll need to use these values in your app's code:
    • If your app shows banner ads, assign these values to the AdUnitId and ApplicationId properties of your AdControl object. For more information, see Banner ads.
    • If your app shows interstitial video ads, pass these values to the RequestAd method of your InterstitialAd object. For more information, see Interstitial ads.

Banner ads

Interstitial ads