Regarding setting the target cpa micros through API

121 views
Skip to first unread message

Pranav Kumar

unread,
Jan 10, 2024, 4:03:45 AM1/10/24
to Google Ads API and AdWords API Forum
Hi
I am trying to set up the target cpa micros but facing the issue. Here are the details of the request made:
Headers: {
  "developer-token": "REDACTED",
  "login-customer-id": "2790970472",
  "x-goog-api-client": "gl-python/3.11.6 grpc/1.57.0 gax/2.11.1 gccl/22.1.0 pb/4.24.2",
  "x-goog-request-params": "customer_id=8065644350"
}
Request: customer_id: "8065644350"
operations {
  create {
    name: "testing camp-60037"
    amount_micros: 1000000
    delivery_method: STANDARD
  }
}
Response
-------
Headers: {
  "google.ads.googleads.v15.errors.googleadsfailure-bin": "\np\n\u0002p\u000b\u00120A campaign budget with this name already exists.\u001a\u0014*\u0012testing camp-60037\"\"\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006create\u0012\u0006\n\u0004name\u0012\u0016j9BnN7xuMy0vF1jJWtIdFA",
  "grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid argument.\u001a\u0001\nDtype.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure\u0012\u0001\np\n\u0002p\u000b\u00120A campaign budget with this name already exists.\u001a\u0014*\u0012testing camp-60037\"\"\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006create\u0012\u0006\n\u0004name\u0012\u0016j9BnN7xuMy0vF1jJWtIdFA",
  "request-id": "j9BnN7xuMy0vF1jJWtIdFA"
}
Fault: errors {
  error_code {
    campaign_budget_error: DUPLICATE_NAME
  }
  message: "A campaign budget with this name already exists."
  trigger {
    string_value: "testing camp-60037"
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "name"
    }
  }
}
request_id: "j9BnN7xuMy0vF1jJWtIdFA"

Google Ads API Forum Advisor

unread,
Jan 10, 2024, 4:21:08 AM1/10/24
to panik...@gmail.com, adwor...@googlegroups.com
Hi,

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

By reviewing your query, I understand that you encountered an error when trying to set up the target cpa micros. Kindly note that the DUPLICATE_NAME error means, A campaign budget with this name already exists. I suggest you to modify the name of the campaign budget to a unique one that isn't already in use within your Google Ads account. Once you've chosen a unique name, update the name field in your request with the new name and resubmit the request. Let me know how it goes after trying the provided suggestion.

 
This message is in relation to case "ref:!00D1U01174p.!5004Q02rVlSi:ref"

Thanks,
 
Google Logo Google Ads API Team


Pranav Kumar

unread,
Jan 10, 2024, 4:29:04 AM1/10/24
to Google Ads API and AdWords API Forum
I had changed them but still this occurs:

Headers: {
  "developer-token": "REDACTED",
  "login-customer-id": "2790970472",
  "x-goog-api-client": "gl-python/3.11.6 grpc/1.57.0 gax/2.11.1 gccl/22.1.0 pb/4.24.2",
  "x-goog-request-params": "customer_id=8065644350"
}
Request: customer_id: "8065644350"
operations {
  create {
    name: "testing camp-60041"
    status: PAUSED
    advertising_channel_type: SEARCH
    campaign_budget: "customers/8065644350/campaignBudgets/13283649992"
    target_cpa {
      target_cpa_micros: 1000000
    }
  }
}
Response
-------
Headers: {
  "google.ads.googleads.v15.errors.googleadsfailure-bin": "\nd\n\u0003\u0003\u0002\u00123The operation is not allowed for the given context.\"(\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006create\u0012\f\n\ntarget_cpa\u0012\u0016mhs9oEcOy2U-TjCslh9syA",
  "grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid argument.\u001a\u0001\nDtype.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure\u0012~\nd\n\u0003\u0003\u0002\u00123The operation is not allowed for the given context.\"(\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006create\u0012\f\n\ntarget_cpa\u0012\u0016mhs9oEcOy2U-TjCslh9syA",
  "request-id": "mhs9oEcOy2U-TjCslh9syA"
}
Fault: errors {
  error_code {
    context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT
  }
  message: "The operation is not allowed for the given context."

  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "target_cpa"
    }
  }
}
request_id: "mhs9oEcOy2U-TjCslh9syA"

Google Ads API Forum Advisor

unread,
Jan 10, 2024, 6:08:09 AM1/10/24
to panik...@gmail.com, adwor...@googlegroups.com
Hi Pranav,

Thank you for getting back to us.

Based on the provided information, I can see that you encountered the OPERATION_NOT_PERMITTED_FOR_CONTEXT error. This means that the operation is not allowed for the given context.  Please note that creating a campaign budget should be done on a client account only and not on a manager account. 

If you are still encountering an error, kindly provide us with the complete API logs (request and response with request-id and request header) generated at your end to assist you better.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby 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.

Pranav Kumar

unread,
Jan 10, 2024, 6:32:35 AM1/10/24
to Google Ads API and AdWords API Forum
Can you you please tell us the way of setting Target CPA in the campaign.

Google Ads API Forum Advisor

unread,
Jan 10, 2024, 10:36:30 AM1/10/24
to panik...@gmail.com, adwor...@googlegroups.com
Hello Pranav,


Thank you for getting back to us.

I will check with our team regarding this issue and will reach out to you once we have an update on it.

Google Ads API Forum Advisor

unread,
Jan 12, 2024, 12:09:40 PM1/12/24
to panik...@gmail.com, adwor...@googlegroups.com
Hi Pranav,


Thank you for getting back to us.

Kindly note that target_cpa can only be set at the portfolio level, meaning it must be configured on a campaign budget and not a campaign (which is what they're attempting). I would suggest you to refer to this Bidding Strategy Types documentation, and please also note that, according to those docs, there are eligibility requirements for using target_cpa, even at the portfolio level.

If you would like to set target_cpa at the standard level (i.e. on the campaign directly), you need to use the maximize conversions, and the request would look similar :
 
operations {
  create {
    name: "testing camp-60041"
    status: PAUSED
    advertising_channel_type: SEARCH
    campaign_budget: "customers/{customerId}/campaignBudgets/{campaign_budget_id}"
    maximize_conversions {
      target_cpa_micros: 1000000
    }
  }
}
Hope this helps. Let us know if you have any further queries.
Reply all
Reply to author
Forward
0 new messages