Need Segmentat Fields in Google Ads campaigns API

53 views
Skip to first unread message

Hashcrypt Devs

unread,
Jun 5, 2024, 6:29:55 PM6/5/24
to Google Ads API and AdWords API Forum
Hi,

We  are retrieving our campaigns data from the Google Ads API: Clicks, Costs, Impressions etc. by campaign.

I want to add a filter on segment.conversion_action_category = 'PURCHASE' also want to add segmenets.conversion_action_category to restrict the results only on purchases. 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": "rQO8VTamZhO8sXdNNOzKsg"
        }
      ]
    }
  }
]

Below is the URL endpoint and 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 the possible solution for this issue.


Google Ads API Forum Advisor

unread,
Jun 6, 2024, 2:06:25 AM6/6/24
to hashcr...@gmail.com, adwor...@googlegroups.com
Hi,

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

I see that you have already raised this concern on another thread with the subject "Google Ads campaigns 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. 
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02tJEHn:ref" (ADR-00238568)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages