Generating Targeting Ideas

The Keyword Planner in the AdWords web interface proposes new keyword ideas based on your existing keywords and website. You can then retrieve historical statistics for keywords (Average CPC, Monthly Search Volume, etc.) to help you decide whether to use these keyword ideas or not.

You can achieve similar goals in the AdWords API with the TargetingIdeaService, that allows you to retrieve targeting ideas from your own tool/platform to help automate account optimization.

Use case

TargetingIdeaService can be used to get new keyword ideas based on a number of inputs, such as:

  • Seed Keywords
  • Seed Ad Group ID
  • Target Website
  • Location
  • Language
  • Product and Services Category
  • And many more

For example, if you're creating a new campaign, or optimizing an existing campaign, you can use the TargetingIdeaService to retrieve a list of candidate keywords based on your existing taxonomy of keywords.

You can use the service to obtain results similar to the functions under Find new keywords and get search volume data in Keyword Planner:

The Keyword Planner function Plan your budget and get forecasts is covered in Estimating Traffic.

Retrieving keyword ideas

The primary input to the TargetingIdeaService is the TargetingIdeaSelector. The following is an example of getting keyword ideas from the TargetingIdeaService by using a couple of seed keywords.

Prepare the request

First, prepare the TargetingIdeaSelector with parameters that indicate the request's purpose is to retrieve keyword ideas:

Java

TargetingIdeaSelector selector = new TargetingIdeaSelector();
selector.setRequestType(RequestType.IDEAS);
selector.setIdeaType(IdeaType.KEYWORD);

Next, select the attributes that must be retrieved. Attributes can be thought of as individual columns/fields that are related to the keyword:

Java

selector.setRequestedAttributeTypes(new AttributeType[] {
    AttributeType.KEYWORD_TEXT,
    AttributeType.SEARCH_VOLUME,
    AttributeType.AVERAGE_CPC,
    AttributeType.COMPETITION,
    AttributeType.CATEGORY_PRODUCTS_AND_SERVICES});

Next, configure the selector's Paging to limit the number of results returned by a single request. Paging is a required field of TargetingIdeaSelector.

Java

// Set selector paging (required for targeting idea service).
Paging paging = new Paging();
paging.setStartIndex(0);
paging.setNumberResults(10);
selector.setPaging(paging);

Finally, use the RelatedToQuerySearchParameter to specify a list of seed keywords from which to generate new ideas:

Java

List<SearchParameter> searchParameters = new ArrayList<>();
// Create related to query search parameter.
RelatedToQuerySearchParameter relatedToQuerySearchParameter =
    new RelatedToQuerySearchParameter();
relatedToQuerySearchParameter.setQueries(new String[] {"bakery", "pastries", "birthday cake"});
searchParameters.add(relatedToQuerySearchParameter);

Once you've configured the TargetingIdeaSelector, send it through the get operation to retrieve keyword ideas:

Java

// Get keyword ideas.
TargetingIdeaPage page = targetingIdeaService.get(selector);

Process the response

The response is composed of a list of TargetingIdea objects. Each TargetingIdea object contains a map of AttributeType associated with an Attribute. It's easier to think of each TargetingIdea object as a data row, each AttributeType as a field/column of the row, and the corresponding Attribute as the value for that data cell.

Java

// Display keyword ideas.
for (TargetingIdea targetingIdea : page.getEntries()) {
  Map<AttributeType, Attribute> data = Maps.toMap(targetingIdea.getData());
  StringAttribute keyword = (StringAttribute) data.get(AttributeType.KEYWORD_TEXT);

  IntegerSetAttribute categories =
      (IntegerSetAttribute) data.get(AttributeType.CATEGORY_PRODUCTS_AND_SERVICES);
  String categoriesString = "(none)";
  if (categories != null && categories.getValue() != null) {
    categoriesString = Joiner.on(", ").join(Ints.asList(categories.getValue()));
  }
  Long averageMonthlySearches =
      ((LongAttribute) data.get(AttributeType.SEARCH_VOLUME))
          .getValue();
  Money averageCpc =
      ((MoneyAttribute) data.get(AttributeType.AVERAGE_CPC)).getValue();
  Double competition =
      ((DoubleAttribute) data.get(AttributeType.COMPETITION)).getValue();
  System.out.printf("Keyword with text '%s', average monthly search volume %d, "
      + "average CPC %d, and competition %.2f "
      + "was found with categories: %s%n", keyword.getValue(), averageMonthlySearches,
      averageCpc.getMicroAmount(), competition,
      categoriesString);
}

The example request selected four attributes, so a sample response may look like this:

KEYWORD_TEXT SEARCH_VOLUME AVERAGE_CPC COMPETITION
cake bakery 170 0.485384 0.41
bakery story 390 0.069918 0.12
... ... ... ...

Retrieving keyword stats

Retrieving historical keyword statistics is very similar to retrieving keyword ideas. The only difference is that the RequestType must be set to STATS instead.

Seeding with an ad group ID

If you already have an existing campaign and ad group, you can retrieve targeting ideas by providing the ad group ID with the SeedAdGroupIdSearchParameter.

Java

SeedAdGroupIdSearchParameter seedAdGroupIdSearchParameter =
    new SeedAdGroupIdSearchParameter();
seedAdGroupIdSearchParameter.setAdGroupId(adGroupId);
searchParameters.add(seedAdGroupIdSearchParameter);

Mapping to Keyword Planner

One of the most frequently asked questions about the TargetingIdeaService is: "Why do the TargetingIdeaService results differ from those of the Keyword Planner tool?"

The reason is that a TargetingIdeaSelector can be configured with more than one different SearchParameter, and the returned results may differ significantly when a different SearchParameter is used.

Select the right network

One of the most common mistakes is not specifying the NetworkSearchParameter. For example, the Keyword Planner may only be searching keyword ideas for the Google Search network, but not for other networks. In this case, make sure to set the NetworkSearchParameter in the TargetingIdeaSelector. For example, to retrieve ideas only for the Search network, set the NetworkSearchParameter like this:

Java

// Create network search parameter (optional).
NetworkSetting networkSetting = new NetworkSetting();
networkSetting.setTargetGoogleSearch(true);
networkSetting.setTargetSearchNetwork(false);
networkSetting.setTargetContentNetwork(false);
networkSetting.setTargetPartnerSearchNetwork(false);

NetworkSearchParameter networkSearchParameter = new NetworkSearchParameter();
networkSearchParameter.setNetworkSetting(networkSetting);
searchParameters.add(networkSearchParameter);

It's important to configure the NetworkSearchParameter consistent with how the potential campaign will be configured.

Search for new keywords using a phrase, website, or category

To implement something similar to this Keyword Planner functionality, each of the input fields can be mapped to a corresponding TargetingIdeaSelector configuration (for example, SearchParameter):

Keyword Planner AdWords API
Your product or service RelatedToQuerySearchParameter
Your landing page RelatedToUrlSearchParameter
Your product category CategoryProductsAndServicesSearchParameter (refer to our Product and Services Categories taxonomy or IDs)
Targeting - Location LocationSearchParameter
Targeting - Language LanguageSearchParameter
Targeting - Network NetworkSearchParameter
Date Range (Monthly Search Volume) Select AttributeType.TARGETED_MONTHLY_SEARCHES
Keyword Filters - Average monthly searches SearchVolumeSearchParameter
Keyword Filters - Competition CompetitionSearchParameter
Include/Exclude Keywords IdeaTextFilterSearchParameter
ExcludedKeywordSearchParameter

Lastly, set the TargetingIdeaSelector.requestType to IDEAS.

The parameters mapping is similar to other functions of this kind:

Keyword Planner AdWords API
Enter keywords RelatedToQuerySearchParameter
Targeting - Location LocationSearchParameter
Targeting - Network NetworkSearchParameter
Date Range (Monthly Search Volume) Select AttributeType.TARGETED_MONTHLY_SEARCHES

Lastly, set the TargetingIdeaSelector.requestType to STATS.

Multiply keyword lists to get new keyword

The AdWords API does not automatically calculate keyword combinations. To achieve the same functionality, you need to programmatically determine the combined keywords list, and then set up the TargetingIdeaSelector accordingly.

Keyword Planner AdWords API
List 1 and List 2 Programmatically combine the two lists and then use the RelatedToQuerySearchParameter
Targeting - Location LocationSearchParameter
Targeting - Network NetworkSearchParameter

Code examples

Each client library contains a complete code example in the Optimization folder:

Send feedback about...

AdWords API
AdWords API
Need help? Visit our support page.