Google Ads campaigns Error

142 views
Skip to first unread message

Hashcrypt Devs

unread,
Jun 5, 2024, 6:29:54 PM6/5/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 and want to add segmenets.conversion_action_category in fields also. But I receive the following error message. 

[
  {
    "error": {
      "code": 400,
      "message": "Request contains an invalid argument.",
      "status": "INVALID_ARGUMENT",
      "details": [
        {
          "@type": "type.googleapis.com/google.ads.googleads.v16.errors.GoogleAdsFailure",
          "errors": [
            {
              "errorCode": {
                "queryError": "PROHIBITED_SEGMENT_WITH_METRIC_IN_SELECT_OR_WHERE_CLAUSE"
              },
              "message": "Cannot select the following segments because at least one unsupported metric is found in SELECT or WHERE clause: 'segments.conversion_action_category'(unsupported metrics: 'average_cost', 'average_cpc', 'average_cpm', 'average_cpv', 'clicks', 'cost_micros', 'ctr', 'engagement_rate', 'engagements', 'impressions', 'interaction_rate', 'interactions', 'video_views')."
            }
          ],
          "requestId": "fZZkpn_bNwMadCHZHsZPzg"
        }
      ]
    }
  }
]

Below is the URL and Param Query we're using:

URL: https://googleads.googleapis.com/v16/customers/7731521629/googleAds:searchStream  

ParamQuery : SELECT campaign.name,
                                    campaign.id,
                                    campaign.status,
                                    metrics.average_cost,
                                    metrics.clicks,
                                    metrics.impressions,
                                    metrics.ctr,
                                    metrics.average_cpc,
                                    metrics.interaction_rate,
                                    metrics.interactions,
                                    metrics.all_conversions_value,
                                    metrics.all_conversions,
                                    metrics.cost_micros,
                                    metrics.conversions,
                                    metrics.average_cpm,
                                    metrics.engagement_rate,
                                    metrics.engagements,
                                    metrics.video_views,
                                    metrics.average_cpv,
                                    campaign.campaign_budget,
                                    segments.conversion_action_category
                                FROM campaign WHERE segments.conversion_action_category = 'PURCHASE' AND segments.date DURING THIS_MONTH

Suggest appropriate solution for this.

Thanks

Google Ads API Forum Advisor

unread,
Jun 5, 2024, 9:49:09 PM6/5/24
to hashcr...@gmail.com, adwor...@googlegroups.com
Hi,

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

Please be informed that I have removed your response from the forums as it contains the PII information.

I see that you have already raised this concern on another thread with the subject 'Google Ads Campaign API error', and we have already responded there for this issue. To avoid multiple threads on the same issue, please take a look at that thread and continue the discussion on the same for further updates on the issue.

However, I am posting the response again here:

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

With this, we verified the provided GAQL query and found that you are mentioning a few incompatible fields (metrics.average_cost, metrics.clicks, metrics.impressions, etc.) with segments.conversion_action_category. So remove these incompatible fields in the select clause and try again.

I highly recommend you utilize the Google Ads Query Builder and Query Validator to build and validate the queries before hitting the API. 

I hope it helps. Please get back to us if you have any further questions or concerns related to the Google Ads API
 

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

Thanks,
 
Google Logo Google Ads API Team


Hashcrypt Devs

unread,
Jun 6, 2024, 10:32:20 AM6/6/24
to Google Ads API and AdWords API Forum
But we want to retrieve the conversion (purchases) for the campaign. can you provide appropriate details to retrieve details with campaign

Hashcrypt Devs

unread,
Jun 6, 2024, 11:49:39 AM6/6/24
to Google Ads API and AdWords API Forum
We're tried with two different queries.

1. Segments fields with other unsupported metrics
URL : https://googleads.googleapis.com/v16/customers/{customer_id}/googleAds:searchStream
Query param : "SELECT campaign.name, campaign.id, campaign.status, metrics.average_cost, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.interaction_rate, metrics.interactions, metrics.all_conversions_value, metrics.all_conversions, metrics.cost_micros, metrics.conversions, metrics.average_cpm, metrics.engagement_rate, metrics.engagements, metrics.video_views, metrics.average_cpv, campaign.campaign_budget, segments.conversion_action_category FROM campaign WHERE segments.conversion_action_category = 'PURCHASE' AND segments.date DURING THIS_MONTH";

Response: image_2024_06_06T07_39_11_177Z.png

2. Only Segments without unsupported metrics
URL : https://googleads.googleapis.com/v16/customers/{customer_id}/googleAds:searchStream
Query  param : "SELECT metrics.all_conversions_value, segments.conversion_action_category, metrics.all_conversions FROM campaign WHERE segments.conversion_action_category = 'PURCHASE'" AND segments.date DURING THIS_MONTH"

Response:
image (2).png

We need segments.conversion_action_category together with the campaign metrics like metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc etc.

Provide the appropriate solution for this.

Thanks
On Thursday, June 6, 2024 at 7:19:09 AM UTC+5:30 Google Ads API Forum Advisor wrote:

Google Ads API Forum Advisor

unread,
Jun 6, 2024, 3:00:12 PM6/6/24
to hashcr...@gmail.com, adwor...@googlegroups.com
Hi,

I would recommend that you try the below query to retrieve campaign data for purchase conversions using shopping_performance_view resource.

Query : "SELECT campaign.name, campaign.id, campaign.status, metrics.all_conversions_value, metrics.all_conversions, metrics.conversions, campaign.campaign_budget, segments.conversion_action_category FROM shopping_performance_view WHERE segments.conversion_action_category = 'PURCHASE' AND segments.date DURING THIS_MONTH"

Please refer to this Google Ads Query builder to build your own query with the shopping_performance_view resource.

Hope this helps. If you have any more queries, please feel free to get back to us.
Reply all
Reply to author
Forward
0 new messages