When it comes to monetization using in-app advertisements in Windows Phone apps, there are quite a few option like Microsoft’s Pubcenter, Mobfox, Smaato, AdDuplex, Nokia’s Inneractive and Google’s Admob. In the past two years I have tried all these ad providers and have finally struck to Google’s Admob. There was a period when Microsoft’s Pubcenter gave the best returns but gradually its fill rates started dropping and earnings dropped by around 99.5% for developers outside US. That made me try other ad providers available for WP and frankly none of them are as good as Pubcenter(the old one) but now developers don’t have a choice. In this post I will show you how you can integrate AdMob in your Windows Phone app. You can add AdMob in your app by XAML or via code in C#.
We have noticed a improved eCPM(0.2 $ to 1.1$) and fill rates(60% to 90%) for pubcenter. So you might consider using pubcenter in your windows phone app.
If you have significant traffic in India then you can give a try to Vserv for Windows Phone 8 which gives a better eCPM than AdMob.
Step 1. Getting the SDK
Firstly download Google Admob SDK for Windows Phone from the link below
Step 2. Creating an ad unit
Go to your AdMob account and create an ad unit for your app
Note: You would need a upgraded Admob account for this purpose and the previous admob account is no longer supported. You can read more about it here.
Fill in the details to create an AdUnit as follows
- Fill in your app name and select platform
- You can configure analytics for your app and link it to your Google analytics account. Learn how to integrate Google analytics in your app. We will skip it for now.
- Select the type of AdUnit and fill in the name for the AdUnit. You can customize the look of the ad whenever you want
- Click on save and an AdUnit id would be generated.
All done you are ready setting thing up for AdMob.
Step 3. Add the GoogleAds reference to your project
Unzip the SDK files and you will find a GoogleAds.dll file in it. Create a new project and add a reference to this dll file in your project. Here’s an article explaining how to integrate a Toolkit or Third party SDK with windows phone app using NuGet Package Manager.
If the GoogleAds.dll is showing as incompatible then follow these steps
- In the file explorer, navigate to the Google Ads.dll
- Right click the dll file and click ‘Properties’
- In the ‘General’ tab, at the bottom, there will be an ‘unblock’ button
- Unblock the dll file and add it again in your project
IMPORTANT: You will need to add the following capabilities in your app for ads to appear!
- ID_CAP_NETWORKING: Access to network services is required when requesting ads.
- ID_CAP_WEBBROWSERCOMPONENT: Required since the AdView is a web browser.
- ID_CAP_MEDIALIB_PLAYBACK: Provides access for currently playing media items.
- ID_CAP_MEDIALIB_AUDIO: Provides read access to audio items in media library.
Now you can either add ads using XAML or via C#
How to add ads using XAML
Go to Toolbox in your Visual Studio and right click on general category and select Choose Items.
From the choose items dialog box tick AdView from Google Ads and click OK to include the control in the Toolbox.
Now you can view AdView control in the Common Controls list of the Toolbox. Select and drag it to place it anywhere in the page
Add the AdUnit ID you generated earlier to the control. The XAML should now look similar to this.
If you have added the XAML code directly then a reference will be required for AdView control
How to add ads using C#
- Add the code below to display ads using C#
- You can see the function admob(StackPanel stck ) takes a parameter which is the name of the stackpanel in which you wish to place your ad. Instead of a stackpanel you could use a Grid too.
- Add the StackPanel in which you wish to place your ad in the XAML
- Call the admob function in the page constructor as follows
- The advantage of this procedure is that you could place multiple ads in different StackPanels or Grid just by changing the name of the StackPanel/Grid in the parameter
Here is how the app looks when you run it in the emulator.