Generating Historical Metrics in Google Ads

Viewed 119

According to the documentation To generate historical metrics: Create a KeywordPlan, KeywordPlanCampaigns, KeywordPlanAdGroups, KeywordPlanCampaignKeywords, and KeywordPlanAdGroupKeywords. Call KeywordPlanService.GenerateHistoricalMetrics with that keyword plan.

These plans come out as a 4-element, slash-delimited string, e.g. customers/1879809528/keywordPlanCampaigns/413340892. However, after modifying the sample code to call GenerateHistoricalMetrics I find that the API at that point expects a long, the KeywordPlanId.

Is this number the 4th item in the plan string? Apparently not, as this slice out of the trace logs indicates:

...
Response
--------
Headers: {
  "content-disposition": "attachment",
  "request-id": "ahE6lqAnzToj3H65rHtHbA",
  "date": "Mon, 30 May 2022 06:39:19 GMT",
  "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
}

{ "results": [ { "resourceName": "customers/1879809528/keywordPlanCampaigns/413340892" } ] }
...
Response
--------
...

Fault: {
  "StatusCode": 3,
  "Details": "Request contains an invalid argument.",
  "RequestId": "mMZTztmu4ufHpgJ77xph9Q",
  "Failure": {
    "errors": [
      {
        "errorCode": {
          "keywordPlanError": "KEYWORD_PLAN_NOT_FOUND"
        },
        "message": "No plan with planId[413340892] exists"
      }
    ],
    "requestId": "mMZTztmu4ufHpgJ77xph9Q"
  }
}

So how does one get from plan to metrics?

0 Answers
Related