How can I use AdControl with multiple AdUnitIds?

Can I use one AdControl in a Windows 8.1 application with multiple AdUnitId s? I followed the approach from various sources on the network to slightly improve the performance of AdControl , but now I found (after adding the event handler to the AdControl ErrorOccurred event) that the error code is NoAdAvailable , which means that there are no ads for the selected category (I'm in Germany) . The code for my AdControl as follows:

  AdControl adControl = new AdControl { ApplicationId = "a1b2c3d4-1a2a-1234-1a2a-1a2b3c4d5e6f", AdUnitId = "123456", HorizontalAlignment = HorizontalAlignment.Left, Height = 250, VerticalAlignment = VerticalAlignment.Top, Width = 250 }; adControl.ErrorOccurred += adControl_ErrorOccurred; 

According to the information provided by Microsoft pubCenter, ApplicationId remains the same (as expected) when I add several categories for ads, but AdUnitId changes. How can I use ads from several categories, is there a simple solution? Or do I need to try to create an AdControl instance by changing the category (and therefore AdUnitId , until I get the exception and then take advantage of this? What would be the best approach?

Update

You are not allowed to modify AdUnitId after installing it, so this will not work.

Update 2

I'm still not sure that everything is configured correctly - when I launch my application (installed from the Windows App Store), I always get the error message "NoAdsAvailable". The category from which ads should be shown is β€œGames,” so the error message states that (for my region) there are no ads from this category. When I use different applications with ads, they show ads, which should be from the category of games, so for some reason I’m afraid that I may not succeed all right.

Does anyone have any ideas?

+7
c # windows-store-apps
source share
1 answer

You will need to use logic to decide which AdUnitId use at any time. This includes choosing different values ​​for different categories for a live application, but also choosing one of the test mode values ​​for AdUnitId and ApplicationId , for viewing here , for the development version. This prevents click fraud.

This page shows how to use the compiler preprocessor directive to make sure that you only use test mode values ​​in the debug version of your application.

Be careful! If you try too often to use the live ad id in the debug app, especially if you click / click ads, your ad id may be paused.


For website:

If people regularly visit links on your site, I would probably just decide to create another AdUnitId every time the page loads.

However, if you have a page that is expected to be viewed statically for a long time, I would use AJAX to pull out a β€œpage” that has only AdControl , and randomly select or rotate AdUnitId to ensure a new ad is AdUnitId every two minutes.

Just be careful that this is not done with excessive speed and that the ads are shown to the user explicitly to avoid any impression of click fraud attempts.


For the store app: (sorry, my brain is missing :)

For a store application, simply recreate a new AdControl with the following AdUnitId on a long timer and add a control. Hide the old control and then dispose of it correctly.

+5
source share

All Articles