How to format query filtering on segments.product_country

74 views
Skip to first unread message

Karl

unread,
Oct 10, 2023, 5:30:10 AM10/10/23
to Google Ads Scripts Forum
Hi,

I am trying to pull shopping performance data from a specific country (Sweden) in an account, but can't figure how the WHERE clause on segments.product_country is supposed to be formatted.  Using the query builder I got:

const query = "SELECT segments.product_item_id, segments.product_country, metrics.clicks FROM shopping_performance_view WHERE segments.product_country = 'SE' AND segments.date DURING LAST_30_DAYS"

but this returned error "MutateError.UNSPECIFIED: Call to GoogleAdsService.Search failed: Resource name 'SE' is malformed: expected 'geoTargetConstants/{criterion_id}'"

So next I tried to include that in the query:

"SELECT segments.product_item_id, segments.product_country, metrics.clicks FROM shopping_performance_view WHERE segments.product_country = 'geoTargetConstants/SE' AND segments.date DURING LAST_30_DAYS"

But that resulted in the error: "Ba: Could not read from Google Ads"

Any tips much appreciated!


Sigurd Fabrin

unread,
Oct 10, 2023, 5:41:28 AM10/10/23
to Google Ads Scripts Forum

Sigurd Fabrin

unread,
Oct 10, 2023, 5:52:00 AM10/10/23
to Google Ads Scripts Forum
found a csv with all the geo target ids https://developers.google.com/google-ads/api/data/geotargets 


Sigurd

Karl

unread,
Oct 10, 2023, 5:58:21 AM10/10/23
to Google Ads Scripts Forum
Thanks a bunch Sigurd!
Reply all
Reply to author
Forward
0 new messages