Google Ads campaigns: PROHIBITED_SEGMENT_WITH_METRIC_IN_SELECT_OR_WHERE_CLAUSE

151 views
Skip to first unread message

Stefan Zehr

unread,
Jun 4, 2024, 10:10:53 AM6/4/24
to Google Ads API and AdWords API Forum
Hi,

we retrieve our campaigns data from the Google Ads API: Clicks, Costs, Impressions etc. by campaign.

I want to add a filter on conversion_action_category = 'PURCHASE' to restrict the results only on purchases. But I receive the following error message. 

What can I do to prevent this from happening?

PROHIBITED_SEGMENT_WITH_METRIC_IN_SELECT_OR_WHERE_CLAUSE

Cannot select the following segments because at least one unsupported metric is found in SELECT or WHERE clause: \'segments.conversion_action_category\'(unsupported metrics: \'absolute_top_impression_percentage\', \'all_conversions_from_interactions_rate\', \'average_cost\', \'average_cpc\', \'average_cpm\', \'clicks\', \'conversions_from_interactions_rate\', \'cost_micros\', \'cost_per_all_conversions\', \'cost_per_conversion\', \'cost_per_current_model_attributed_conversion\', \'ctr\', \'impressions\', \'interaction_rate\', \'interactions\', \'top_impression_percentage\'

Google Ads API Forum Advisor

unread,
Jun 4, 2024, 1:58:25 PM6/4/24
to s.z...@group-apo.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out to the Google Ads API support team.

The PROHIBITED_SEGMENT_WITH_METRIC_IN_SELECT_OR_WHERE_CLAUSE is encountered because a segment may have been included together with a metric that it is incompatible with in the SELECT or WHERE clause. For more information, you may see this document about segmentation

However, if your issue still persists, kindly provide us with the complete API logs (request and response with request-id and request header) generated at your end where the mentioned error occurred.

If you are using a client library and haven't enabled logging yet, I would request that you enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via the Reply privately to the author option or a direct private reply to this email. 

This message is in relation to case "ref:!00D1U01174p.!5004Q02tJCk2:ref" (ADR-00238183)

Thanks,
 
Google Logo Google Ads API Team


Killian Coq

unread,
Jun 5, 2024, 6:29:59 PM6/5/24
to Google Ads API and AdWords API Forum
Hi, 
We are having the same issue. 
We can't get a specific conversion (purchases) for campaigns.
Could you provide guidance on this ?

Maybe provide a working exemple ?

Thanks !

Google Ads API Forum Advisor

unread,
Jun 6, 2024, 1:13:38 AM6/6/24
to coq.k...@gmail.com, adwor...@googlegroups.com
Hi,

The segments.conversion_action_category is incompatible with the metrics cost, impressions and clicks in the campaign report.  
You may try the below query to retrieve the conversion action category 'PURCHASE' using the conversion_action report. The conversion_action report does not contain the campaign details.
SELECT conversion_action.id, conversion_action.name, metrics.all_conversions, conversion_action.category FROM conversion_action WHERE conversion_action.category = 'PURCHASE'
If you would still like to retrieve the conversion (purchases) for the campaign, provide us with the uncropped screenshot of the Google Ads account by highlighting the metrics cost, impressions and clicks along with the segment ''PURCHASE".

Christian H.

unread,
Jun 6, 2024, 1:48:51 AM6/6/24
to Google Ads API and AdWords API Forum
I like the Query Builder tool in the Google Ads API documentation. It interactively shows what fields are available for the SELECT statement.
If you go to https://developers.google.com/google-ads/api/fields/v16/campaign_query_builder and add "segments.conversion_action" you'll see right away that only conversion related metrics are allowed in the query. clicks, impressions, ctr etc are greyed out.

Killian Coq

unread,
Jun 6, 2024, 11:49:38 AM6/6/24
to Google Ads API and AdWords API Forum
Hi and thank you for your answer !

It is very important for us to get the conversions (for exemple, purchases) at campaign level. Having them only at account level is not enough for analysis. 

Here is a screenshot with  the metrics cost, impressions and clicks along with the segment ''PURCHASE" (it's in french, "Achat" = "Purchase").

So how can we get the detailed purchases by campaign ?

Thank you !
2024-06-06_10h25_40.png
Screen Google Ads.png

Google Ads API Forum Advisor

unread,
Jun 6, 2024, 4:10:29 PM6/6/24
to coq.k...@gmail.com, adwor...@googlegroups.com
Hi,

Kindly note that retrieval of detailed purchases at the campaign level is not yet supported in the Google Ads API. 

I will raise a request to add this feature to be available in the Google Ads API. We cannot provide a scheduled timeline for the availability of this feature in the Google Ads API. I would recommend you please follow our Release Notes and Blog Post for future updates.

Killian Coq

unread,
Jun 6, 2024, 5:17:04 PM6/6/24
to Google Ads API and AdWords API Forum
Thank you for your answer. 

Is it possible to get detailed purchases at ad group level or at ad level ? 

Stefan Zehr

unread,
Jun 7, 2024, 1:49:30 AM6/7/24
to Google Ads API and AdWords API Forum
Thank you all for the replies, for us it was sufficient to just query only the conversions metric on campaign level (this is not prohibitted) and then filter by conversion_action_category <> 'PURCHASE' . We then could adjust the conversion metric in our main query (with impressions, costs, etc.) by subtracting these non purchase conversions.

Google Ads API Forum Advisor

unread,
Jun 7, 2024, 2:31:11 AM6/7/24
to coq.k...@gmail.com, adwor...@googlegroups.com
Hi,

Note that retrieval of detailed purchases at the ad group level or at ad level is not possible in the Google Ads  API. The segments.conversion_action_category is incompatible with the metrics cost, impressions and clicks in the ad group level report. 
Reply all
Reply to author
Forward
0 new messages