How to get Audience segment and Type?

918 views
Skip to first unread message

陳泓霖

unread,
Oct 5, 2022, 5:18:55 AM10/5/22
to Google Ads API and AdWords API Forum
Hi team, I want to get all fields like UI shows.
1664960692946.jpg
I use
SELECT campaign.name, ad_group.name, ad_group_audience_view.resource_name, metrics.clicks, metrics.conversions, metrics.impressions, metrics.cost_micros FROM ad_group_audience_view
and it returns fields without Audience segment and Type,
How can I get all fields in the same request. Thanks.

English is not my native language, please forgive my grammar mistakes.

Google Ads API Forum Advisor

unread,
Oct 5, 2022, 9:01:42 AM10/5/22
to an...@bluerain.com.tw, adwor...@googlegroups.com
Hi,

Thank you for raising this concern to the Google Ads API Forum.

With regard to your concern, the following fields to get the audience segments and type as can be seen in the provided UI:
With this, you may try the below query:

SELECT campaign.name, ad_group.name, ad_group_audience_view.resource_name, ad_group_criterion.type, ad_group_criterion.display_name, metrics.clicks, metrics.conversions, metrics.impressions, metrics.cost_micros FROM ad_group_audience_view

I hope it helps, let me know what goes after.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2exbav:ref

Google Ads API Forum Advisor

unread,
Oct 5, 2022, 10:42:20 AM10/5/22
to adwor...@googlegroups.com, an...@bluerain.com.tw
Hi,

Just to add to my previous response, this ad_group_criterion.display_name field will display the name of the criterion. The ad_group_criterion.type field will display the type of the criterion. However, to get the audience segment, you may use the user_list.name field and for the type, you may use the user_list.type field. Let me know if this works for you.

陳泓霖

unread,
Oct 5, 2022, 10:34:51 PM10/5/22
to Google Ads API and AdWords API Forum
Hi,
I use
SELECT campaign.idcampaign.name,campaign.status, ad_group.id,ad_group.name,ad_group.status,ad_group_criterion.display_name,ad_group_criterion.type FROM ad_group_audience_view
I can get result : display_name = uservertical::80311
but I want user_list.name
How to correspond  user_list.name in this request ?

thank you

adsapi 在 2022年10月5日 星期三晚上10:42:20 [UTC+8] 的信中寫道:

Google Ads API Forum Advisor

unread,
Oct 6, 2022, 1:12:48 AM10/6/22
to an...@bluerain.com.tw, adwor...@googlegroups.com
Hi,

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

You may try adding the user_list.name field for audience segment list name and for the type, you may use the user_list.type field

Let me know if you have further questions.

Regards,
Google Logo
Ernie John
Google Ads API Team
 


ref:_00D1U1174p._5004Q2exbav:ref

陳泓霖

unread,
Oct 6, 2022, 1:27:06 AM10/6/22
to Google Ads API and AdWords API Forum
Hi,
I tried
SELECT campaign.idcampaign.name,campaign.status, ad_group.id,ad_group.name,ad_group.status,ad_group_criterion.display_name,ad_group_criterion.type,user_list.name FROM ad_group_audience_view WHERE segments.date BETWEEN 20220801 AND 20220831  AND campaign.status != "PAUSED"  AND campaign.status != "REMOVED"   ';
and it return 
messageImage_1665033666520.jpg
{ "message": "Request contains an invalid argument.", "code": 3, "status": "INVALID_ARGUMENT", "details": [ { "@type": 0, "data": "type.googleapis.com\/google.ads.googleads.v11.errors.GoogleAdsFailure" }, { "@type": 0, "data": [ { "errorCode": { "queryError": "PROHIBITED_METRIC_IN_SELECT_OR_WHERE_CLAUSE" }, "message": "Cannot select or filter on the following metrics: 'average_cpc'(could not support requested resources: 'USER_LIST'), 'clicks'(could not support requested resources: 'USER_LIST'), 'cost_micros'(could not support requested resources: 'USER_LIST'), 'impressions'(could not support requested resources: 'USER_LIST'), since metric is incompatible with the resource in the FROM clause or other selected segmenting resources." } ] }, { "@type": 0, "data": "UOjq-I7J5kB7xJRA5ikszw" } ] }

How to fix it?
thank you.
adsapi 在 2022年10月6日 星期四下午1:12:48 [UTC+8] 的信中寫道:

Google Ads API Forum Advisor

unread,
Oct 6, 2022, 5:20:00 AM10/6/22
to an...@bluerain.com.tw, adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

Based on the screenshot of the error message that you encountered, metrics is prohibited in the where clause because it is not compatible to user_list. It is true. Because, the Segment date is incompatible with user_list.name also with user_list.id. Therefore, you may try the query below:

  • SELECT ad_group_audience_view.resource_name, campaign.name, campaign.status, ad_group_criterion.type, ad_group_criterion.display_name, ad_group_criterion.criterion_id, user_list.name, user_list.id FROM ad_group_audience_view WHERE campaign.status = 'PAUSED'
 
In addition, we cannot use the Removed status in the campaign for segmentation because it will not return any results.

Please let us know if this works for you.

Kind regards,
Google Logo
Sherwin Vincent
Google Ads API Team
 


ref:_00D1U1174p._5004Q2exbav:ref
Reply all
Reply to author
Forward
0 new messages