'How to get monthly search volume for the past period of time for the array of keywords from the new Google Ads API
We use to get monthly search volume for a set of keywords from the Google AdWords API by using this method from AdWords API documentation TargetingIdeaSelector
So the first step was to create a selector with an array of keywords and other parameters
@selector = {
idea_type: 'KEYWORD', request_type: 'STATS',
requested_attribute_types: %w[SEARCH_VOLUME AVERAGE_CPC TARGETED_MONTHLY_SEARCHES KEYWORD_TEXT],
search_parameters: [
{ xsi_type: 'RelatedToQuerySearchParameter', queries: @keywords_array },
{ xsi_type: 'LanguageSearchParameter', languages: [{ id: @language.criteria_id }] },
{ xsi_type: 'NetworkSearchParameter', network_setting: {
target_partner_search_network: false,
target_google_search: true,
target_search_network: false,
target_content_network: false
} }
],
paging: { start_index: 0, number_results: 500 }
}
And the second step was to pass this selector to AdWords API via TargetingIdeaSelector method
response = TargetingIdeaSelector.get(@selector)
Then we just needed to parse the response body.
But Google AdWords API is going to be deprecated in April 2022 and replaced with Google ads API
Google's migration guide doesn't say what is the replacement for TargetingIdeaSelector in the new Google ads API. Google's API support says that to get search volume we have to use this method KeywordPlanService.GenerateHistoricalMetrics
But this documentation isn't very unclear.
So my question is - if I have an array of keywords
@keywords_array = ["flats for sale london", "houses for sale london", "bungalows for sale london"]
How to get search volume for the last 3 months and 12 months for the keywords in the @keywords_array from the new Google ads API?
Any code samples are welcome as I could not find this information in Google AdWords API documentation.
Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
