Hello Ernie

Thanks for the help. With what you suggested I was able to work out the code 
below. Sadly, it doesn’t do anything more than before. However, the associate 
documentation states that AverageCpc is deprecated.

Oh well.

Kind regards,
Bruce.

        public static (GenerateHistoricalMetricsResponse response, 
GoogleAdsException exception) GenerateHistoricalMetrics(GoogleAdsClient client, 
string plan)
        {
            KeywordPlanServiceClient kpServiceClient = 
client.GetService(Services.V11.KeywordPlanService);

            GenerateHistoricalMetricsRequest generateHistoricalMetricsRequest = 
new GenerateHistoricalMetricsRequest()
            {
                KeywordPlan = plan,
                HistoricalMetricsOptions = new 
Google.Ads.GoogleAds.V11.Common.HistoricalMetricsOptions() { IncludeAverageCpc 
= true },
                AggregateMetrics = new 
Google.Ads.GoogleAds.V11.Common.KeywordPlanAggregateMetrics()
            };
            try
            {
                var response = 
kpServiceClient.GenerateHistoricalMetrics(generateHistoricalMetricsRequest);
                return (response, null);
            }
            catch (GoogleAdsException e)
            {
                return (null, e);
            }

        }


From: Google Ads API Forum Advisor <adsapi@forumsupport.google>
Sent: Friday, 22 July 2022 1:17 PM
To: Bruce Axtens <br...@searchsmart.com.au>
Cc: Steve Poulson <st...@searchsmart.com.au>; adwords-api@googlegroups.com
Subject: RE: How to enable AverageCpcMicros on GenerateHistoricalMetrics in 
V11's KeywordPlanService?

Hi Bruce,

Thank you for providing more details to your concern. I am also a member of the 
Google Ads API team and let me provide support to your concern.

If you want to include the 
average_cpc_micros<https://developers.google.com/google-ads/api/reference/rpc/v11/KeywordPlanHistoricalMetrics#average_cpc_micros>
 in response, then as initially mentioned by my colleague (Carmela), you will 
need to set the 
include_average_cpc<https://developers.google.com/google-ads/api/reference/rpc/v11/HistoricalMetricsOptions#include_average_cpc>
 as true in the 
KeywordPlanService.GenerateHistoricalMetrics<https://developers.google.com/google-ads/api/reference/rpc/v11/KeywordPlanService#generatehistoricalmetrics>
 request. Please note that the 
historical_metrics_options<https://developers.google.com/google-ads/api/reference/rpc/v11/GenerateHistoricalMetricsRequest#historical_metrics_options>
 is an object of the 
KeywordPlanService.GenerateHistoricalMetrics<https://developers.google.com/google-ads/api/reference/rpc/v11/KeywordPlanService#generatehistoricalmetrics>
 not just by the keywords ideas. This is the configuration that is missing in 
your request so the average cpc is missing as well in the response.

Unfortunately, there is no sample code that illustrate setting of this field in 
KeywordPlanService.GenerateHistoricalMetrics<https://developers.google.com/google-ads/api/reference/rpc/v11/KeywordPlanService#generatehistoricalmetrics>.
 With this, I would suggest reaching out to the author of the .Net client 
library via this link<https://github.com/googleads/google-ads-dotnet/issues> to 
know how you can implement the said field in the 
KeywordPlanService.GenerateHistoricalMetrics<https://developers.google.com/google-ads/api/reference/rpc/v11/KeywordPlanService#generatehistoricalmetrics>.
 They are more equipped to provide support on code related concerns.

Regards,

[Google Logo]
Ernie John
Google Ads API Team

[https://google-dev-relations.my.salesforce.com/servlet/servlet.ImageServer?oid=00D1U000001174p&esid=0184Q00001I9DXZ&from=ext]

ref:_00D1U1174p._5004Q2bmEgh:ref

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/ME3P282MB1729FE6648350644302A8C2D9B909%40ME3P282MB1729.AUSP282.PROD.OUTLOOK.COM.
  • Ho... Bruce Axtens
    • ... Bruce Axtens
      • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
        • ... Bruce Axtens
          • ... Bruce Axtens

Reply via email to