Search Ads for Mobile Apps

Read the updated version.

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 tagForChildDirectedTreatment: method. Requests will fail if tagForChildDirectedTreatment is set.

These steps provide the setup for the basic service:

  1. 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.

  2. Follow the steps to create a GADSearchBannerView in 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];
  3. Create a new GADSearchRequest object and set the query:

    GADSearchRequest *adRequest = [GADSearchRequest request];
    adRequest.query = @"flower";
  4. Call loadRequest: to show the ad:

    [banner loadRequest:adRequest];

Ad Controls

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 ads.

GADSearchRequest

Properties

query
The query for requesting search ads. If this is not set, the user won't get any ads.
backgroundColor
The background color for the ad. This should be set using the setBackgroundSolid: method.
gradientFrom
The color to start the background gradient. This should be set using the setBackgroundGradientFrom:toColor: method.
gradientTo
The color to end the background gradient. This should be set using the setBackgroundGradientFrom:toColor: method.
headerColor
The ad header text color.
descriptionTextColor
The ad description text color.
anchorTextColor
The ad URL text color.
fontFamily
The font used to render the ad.
headerTextSize
The font size of the header text.
borderColor
The border color to render the ad container. This property is ignored if border type is set to kGADSearchBorderTypeNone.
borderType
The border type to render the ad.
borderThickness
The thickness of the border around the ad container.
customChannels
Adds channel information to the ad request. This should contain a list of channel IDs separated by '+'.

Methods

(void)setBackgroundSolid:(UIColor *)color;
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 setBackgroundSolid: and setBackgroundGradientFrom:toColor: are set, only the latter is considered.