This guide is provided for Apps developers who want to enhance monetization on their apps' search results pages. With this service, apps can target ads based on users' search queries, access Google's AdWords inventory, and help users find what they're looking for.
The implementation is very similar to that of the existing AdMob ads. The main difference is that a search term is also supplied to the SDK when an ad call is placed.
Search ads does not support the
method. Requests will fail if
tagForChildDirectedTreatment is set.
These steps provide the setup for the basic service:
Make sure you have downloaded the latest SDK containing in its "Add-ons" folder all the necessary header files. Set up the SDK as you would for AdMob.
Follow the steps to create a
GADSearchBannerViewin the same way you would create a
GADBannerView, except use your AdSense Publisher ID in place of your AdMob ID.
Note: Attempting to request search ads with your AdMob ID will not work.
GADSearchBannerView *banner = [[GADSearchBannerView alloc] initWithAdSize:kGADAdSizeBanner];
Create a new
GADSearchRequestobject and set the query:
GADSearchRequest *adRequest = [GADSearchRequest request]; adRequest.query = @"flower";
loadRequest:to show the ad:
You have control over the appearance of the ad including:
- Background color/gradient
- Border color/type/thickness
- URL text colors (header/description/visible)
- Ad font
- Font size of the ad header—this determines the description and visible URL sizes. Verify that your container is big enough to show the ad.
More details about controls can be found in the class
GADSearchRequest. These controls must be set before requesting
- The query for requesting search ads. If this is not set, the user won't get any ads.
- The background color for the ad. This should be set using the
- The color to start the background gradient. This should be set using the
- The color to end the background gradient. This should be set using the
- The ad header text color.
- The ad description text color.
- The ad URL text color.
- The font used to render the ad.
- The font size of the header text.
- The border color to render the ad container. This property is ignored if border type is set to
- The border type to render the ad.
- The thickness of the border around the ad container.
- Adds channel information to the ad request. This should contain a list of channel IDs separated by '+'.
- Sets a solid background color for rendering the ad.
(void)setBackgroundGradientFrom:(UIColor *)from toColor:(UIColor *)toColor;
- Sets a linear gradient background color for rendering the ad.
Note: If both
setBackgroundGradientFrom:toColor: are set, only the latter is