I'm on migration from the old Google AdWords API to the new Google Ads API, using PHP-SDK by Google.

This is the use case, where I'm stuck:

I feed an amount of keywords (paginating them by keyword plans a 10k) to generateHistoricalMetrics($keywordPlanResource) and collect the results.

To do so I followed instructions at https://developers.google.com/google-ads/api/docs/keyword-planning/generate-historical-metrics and, especially, https://developers.google.com/google-ads/api/docs/keyword-planning/generate-historical-metrics#mapping_to_the_ui, with using of KeywordPlanAdGroupKeywords (with a single ad group) and avoiding to pass a specific date range for now, relying on the default value.

Further I had to apply some filters on my keywords because of KEYWORD_HAS_INVALID_CHARS and KEYWORD_TEXT_TOO_LONG, but all the errors which I'm aware of are gone now.

Now, I found out, that the KeywordPlanHistoricalMetrics object does not contain any keyword id (of the form customers//keywordPlanAdGroupKeywords/) So, I have to rely on the correct ordering. This is ok as it seems, that the original ordering of keywords is preserved within the results, as here https://developers.google.com/protocol-buffers/docs/encoding#optional

But still I have the problem, that count($keywordPlanServiceClient->generateHistoricalMetrics($keywordPlanResource)->getMetrics()) is lower then count($passedKeywords), where each of $passedKeywords where passed to

new KeywordPlanAdGroupKeyword([ 'text' => $passedKeyword, 'match_type' => KeywordMatchType::EXACT 'keyword_plan_ad_group' => $planAdGroupResource ]); 

Q: So I have two questions here:

  1. Why getMetrics() does not yield the same amount of results as the amount of passed keywords?

  2. I'm struggling with debugging at this moment: Say, I want to know which keywords are let out. Either for providing more information at this place or just to skip them, and let my customer know, that these particular keywords were not queried. How to do this, when although I have a keyword id for every passed keyword I cannot match the returned metrics to them, because the KeywordPlanHistoricalMetrics object does not contain any keyword id.

Detail: While testing I found out, that the reducing of an amount of queried keywords reduces the amount of lost keyword data:

  • 10k of queried keywords - 4,72% loss,
  • 5k - 2,12%,
  • 2,5k - 0,78%,
  • 1,25k - 0,43%,
  • 625 - 0,3%,
  • 500 - 0,24%,
  • 250 - 0,03%
  • 200 - 0,03% of lost keywords.

But I can't imagine, that keywords should be queried one by one.

Tag:google-ads-api

Add a new comment.