Hello,
i see significant discrepancies between average monthly searches that i see 
in UI and the values i get from API (30-40%) for all keywords.
Month and year are the same in API call and in UI. What could be the reason?
My python script below, thanks for help!

client = GoogleAdsClient.load_from_dict(credentials)

keyword_plan_service = client.get_service("KeywordPlanService")
metric_request = client.get_type("GenerateHistoricalMetricsRequest")
resource_name = keyword_plan_service.keyword_plan_path('1234', '5678')

metric_request.keyword_plan = resource_name
metric_request.historical_metrics_options.year_month_range.start.year=2021
metric_request.historical_metrics_options.year_month_range.start.month=client.get_type("MonthOfYearEnum").MonthOfYear.MARCH
metric_request.historical_metrics_options.year_month_range.end.year=2021
metric_request.historical_metrics_options.year_month_range.end.month=client.get_type("MonthOfYearEnum").MonthOfYear.MARCH

response = keyword_plan_service.generate_historical_metrics(metric_request)

for record in response.metrics:
  print({
    "search_query": record.search_query,
    "avg_monthly_searches": record.keyword_metrics.avg_monthly_searches,
  })

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/adbe1211-9d74-494c-8cb9-9bc747427a07n%40googlegroups.com.

Reply via email to