How to get MonthlySearchVolume from the new Google Ads API?

1,556 views
Skip to first unread message

Ruslan

unread,
Nov 18, 2021, 7:07:39 AM11/18/21
to AdWords API and Google Ads API Forum
How to get MonthlySearchVolume for single or multiple keywords from the new Google Ads API (Not from Adwords API as it is going to be deprecated soon)? 
This field is visible in the Google Ads API V9 here but not clear how to get data for this field.

In the old Google Adwords API we use to generate a request with the following params 
Screenshot from 2021-11-18 12-05-26.png
and passed to the TargetingIdeaService . In the response from an API we are receiving SEARCH_VOLUME for KEYWORD_TEXT 

My main question is how to get the same data from the new Google Ads API???
 

Google Ads API Forum Advisor

unread,
Nov 18, 2021, 12:37:59 PM11/18/21
to r...@semetrical.com, adwor...@googlegroups.com
Hi Ruslan,

The Generate Historical Metrics guide in Ads API gives an overview which includes a migration guide from AdWords. Feel free to get back to us.

Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey

​​​​​​​Regards,
 
Google Logo
Aryeh Baker
Google Ads API Team
 
 

ref:_00D1U1174p._5004Q2RA8Jm:ref

Ruslan

unread,
Nov 19, 2021, 4:23:12 AM11/19/21
to AdWords API and Google Ads API Forum
Hi, thank you for your reply. But could you please provide a sample of how to get "Monthly Search Volume" for any keyword based on GenerateHistoricalMetricsRequest that you are referencing to? As in the documentation that you are providing including documentation for migration it isn't clear how to get  "Monthly Search Volume" from the GenerateHistoricalMetrics .  

Google Ads API Forum Advisor

unread,
Nov 19, 2021, 9:16:16 AM11/19/21
to r...@semetrical.com, adwor...@googlegroups.com
Hi Ruslan,

Here are the prerequisites in Ads API to generate historical metrics. You can follow the sample code on the page and change the code explained in generate forecast metrics to generate historical metrics instead of forecast metrics. For our client libraries here's sample ad keyword plan code and here's sample Generate Forecast Metrics code that can be easily modified to return historical metrics instead.

I just now modified the sample Java generate forecast metrics code as explained above and turned on the logger with the logger set to 'DEBUG' and saw results per month in the response from the API.

Ruslan

unread,
Nov 19, 2021, 9:51:34 AM11/19/21
to AdWords API and Google Ads API Forum
Hi Aryeh. Thank you for your reply and the code samples that you have provided. But it is still not what I was asking for. My original question was how to get historical monthly search volume for a particular keyword, not forecasted. 
So let me please rephrase my question.
Could you please provide a code sample of how to get monthly search volume for the keyword: "flats for sale in London"  for the past 3 months or for the past 12 months period of time from the new Google Ads API ? 

Google Ads API Forum Advisor

unread,
Nov 19, 2021, 3:51:32 PM11/19/21
to r...@semetrical.com, adwor...@googlegroups.com
Hi Ruslan,

The guide has instructions how to convert the "generate forecast metrics" code sample so that it generates historical metrics instead. Both programs have to run in order to generate using a library. 

We don't have a sample that is already set up to generate historical metrics, presumably because it's so similar to generating forecast metrics and conversion of the sample is a trivial thing. I modified the sample Generate Forecast Metrics code to generate historical metrics and ran it successfully before answering you the last time.

Let me lay out what I was trying to convey in the email before in a way that is action oriented:
  1. Run the  sample ad keyword plan code 
  2. Change the code in generate forecast metrics to generate historical metrics instead of forecast metrics Here's the sample Generate Forecast Metrics code.
  3. Turn on the logger with the logger set to 'DEBUG'
  4. Run that modified sample to pull your historical metrics.
Feel free to get back to us.

Ruslan

unread,
Nov 22, 2021, 5:17:48 AM11/22/21
to AdWords API and Google Ads API Forum
Hi Aryeh. Thank you for your reply. But it is still not clear how to get a monthly search volume for an array of keywords. 
For example, if I have an array of keywords @keywords = ['cars for sale', 'used cars for sale', 'new cars for sale' ] and I need to get monthly a search volume for the past 3 months for each of these keywords.

According to documentation that you provided the first step that I need to do is to create a keywords plan object:

client = Google::Ads::GoogleAds::GoogleAdsClient.new
  keyword_plan = create_keyword_plan(client, customer_id)

Could you please explain and provide code samples of the following: 
1) How to pass an array of keywords @keywords into the keyword_plan  object in order to receive monthly search volume for these keywords in the array?
2) Ho to specify a needed past period of time, for example for the past 3 months? How to tell API that we need monthly search volume for the past 3 months?

Thanks. 

Google Ads API Forum Advisor

unread,
Nov 22, 2021, 5:11:10 PM11/22/21
to r...@semetrical.com, adwor...@googlegroups.com
Hi Ruslan,

The  sample ad keyword plan code have 3 adGroup keywords, you can change then to the ones you want. The  sample Generate Forecast Metrics code which you can modify will give you 12 months of historical keyword data for each of those adGroup keywords.

Ruslan

unread,
Dec 8, 2021, 10:11:46 AM12/8/21
to AdWords API and Google Ads API Forum

Hi. Aryeh. 


Thanks for your previous reply. But we are still having some issues with a new api. 

One of the first steps of getting data from api is to create a client and pass security credentials into the client. The problem that we have is when credentials are not valid the API gets stuck and holds the request without response and without any timeout or error responses. For example, please see the code below.


Step 1. Creating a new client with invalid credentials 


client = Google::Ads::GoogleAds::GoogleAdsClient.new do |config| config.client_id = my_valid_adwords_client_id config.client_secret = my_valid_adwords_client_secret config.login_customer_id = my_valid_customer_id config.refresh_token = 'invalid refresh token' config.developer_token = my_valid_adwords_developer_token end

Step 2. Trying to retrieve a data from API by using invalid client from Step 1


def create_keyword_plan operation = client.operation.create_resource.keyword_plan do |kp| kp.name = "Keyword plan for traffic estimate ##{timestamp}" kp.forecast_period = client.resource.keyword_plan_forecast_period do |fp| fp.date_interval = :NEXT_QUARTER end end keyword_plan_service = client.service.keyword_plan response = keyword_plan_service.mutate_keyword_plans(customer_id: my_valid_customer_id, operations: [operation]) response.results.first.resource_name end


When code execution reaches this line 

 response = keyword_plan_service.mutate_keyword_plans(customer_id: my_valid_customer_id, operations: [operation])

The API gets stuck with no response. The longes that we waited was 30 min. 


My questions are. Is there any way to avoid API from getting stuck if client data is invalid? And what is the API response timeout? Or how to handle cases like this? 

Thanks. 

Google Ads API Forum Advisor

unread,
Dec 9, 2021, 12:57:08 PM12/9/21
to r...@semetrical.com, adwor...@googlegroups.com
Hi Ruslan,

For this issue I suggest you log at 'DEBUG' level, if you catch an error when the program hangs then you can send this issue including the logs generated plus system logs to the Ruby Ads API Client Library issue tracker.
Reply all
Reply to author
Forward
0 new messages