KeywordPlanAggregateMetrics option in GenerateHistoricalMetricsRequest

327 views
Skip to first unread message

Jakub Tomaszewski

unread,
Aug 26, 2021, 5:40:34 AM8/26/21
to AdWords API and Google Ads API Forum
Hi,
I'm trying to GenerateHistoricalMetricsRequest with aggregate_metrics in order to get search volume for every device type, but I can't make it work.

My code (Python):
keyword_plan_service = client.get_service("KeywordPlanService")
metric_request =  client.get_type("GenerateHistoricalMetricsRequest")
resource_name = keyword_plan_service.keyword_plan_path(client_id, keywordplan)
metric_request.keyword_plan=resource_name
metric_request.historical_metrics_options.year_month_range.start.year=2020
metric_request.historical_metrics_options.year_month_range.start.month=client.get_type("MonthOfYearEnum").MonthOfYear.JANUARY
metric_request.historical_metrics_options.year_month_range.end.year=2020
metric_request.historical_metrics_options.year_month_range.end.month=client.get_type("MonthOfYearEnum").MonthOfYear.MARCH
metric_request.aggregate_metrics.aggregate_metric_types = [client.get_type("KeywordPlanAggregateMetricTypeEnum").KeywordPlanAggregateMetricType.DEVICE]
response =  keyword_plan_service.generate_historical_metrics(metric_request)

metric_request returns this:

keyword_plan: "customers/<client_id>/keywordPlans/<keywordplan>"

aggregate_metrics {

  aggregate_metric_types: DEVICE

}

historical_metrics_options {

  year_month_range {

    start {

      year: 2020

      month: JANUARY

    }

    end {

      year: 2020

      month: MARCH

    }

  }

}


(client_id and keywordplan are specified earlier).

Request above returns data in total, without breaking down by device. It doesn't make any difference if I pass metric_request.aggregate_metrics.aggregate_metric_types or not. My guess is that I specify it incorrectly. Calling client.get_type("KeywordPlanAggregateMetricTypeEnum").KeywordPlanAggregateMetricType.DEVICE 
returns: <KeywordPlanAggregateMetricType.DEVICE: 2>

Any idea how to fix this?

Jakub Tomaszewski

unread,
Aug 31, 2021, 3:33:51 AM8/31/21
to AdWords API and Google Ads API Forum
Nevermind, it's all working correctly when querying more keywords. I was querying 2 keywords that's why nothing was returned.

Google Ads API Forum Advisor

unread,
Sep 1, 2021, 11:13:00 PM9/1/21
to jakub.to...@performance-media.pl, adwor...@googlegroups.com
Hi Jakub,

I am happy to know that the issue has been fixed on your end.

If you have further concerns that are related to the Google Ads API, let us know and we will be happy to address it.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2MixB1:ref

Alex

unread,
Jan 23, 2025, 5:37:35 AMJan 23
to Google Ads API and AdWords API Forum
Jakub, did you manage to get a breakdown of device data? I can't seem to..

Google Ads API Forum Advisor

unread,
Jan 23, 2025, 5:27:24 PMJan 23
to alexc...@gmail.com, adwor...@googlegroups.com
Hi,

If you have queries related to Google Ads API, please feel free to get back to us.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02MixB1:ref" (ADR-00076887)

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5


 


Message has been deleted

Alex

unread,
Jan 24, 2025, 3:50:28 AMJan 24
to Google Ads API and AdWords API Forum
KeywordPlanAggregateMetricType.DEVICE doesnt return anything

Google Ads API Forum Advisor

unread,
Jan 24, 2025, 3:01:09 PMJan 24
to alexc...@gmail.com, adwor...@googlegroups.com
Hi,

Could you please provide us with the complete API logs (request and response with request-id and request header) generated at your end, so that we can investigate this issue further.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag. 

Google Ads API Forum Advisor

unread,
Jan 24, 2025, 3:03:01 PMJan 24
to alexc...@gmail.com, adwor...@googlegroups.com
Hi,

Kindly disregard my previous mail. Could you please provide us with the complete API logs (request and response with request-id and request header) generated at your end, so that we can investigate this issue further.


If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag. 

You can send the details via Reply privately to the author option, or direct private reply to this email.
Reply all
Reply to author
Forward
0 new messages