API Bidding

399 views
Skip to first unread message

Adrian Lazar

unread,
Jul 12, 2023, 6:32:58 AM7/12/23
to Google Ads API and AdWords API Forum
Hello,

I've been struggling to integrate API Bidding Updates (Mutates) for Campaigns and AdGroups.

Library used: Google Ads API Python Client Library
Version: 21.2.0

Currently, I've only managed to get working API Bidding Updates (Mutates) for Campaigns using TARGET_ROAS and TARGET_CPA, and for AdGroups using MANUAL_CPC, MANUAL_CPM and TARGET_CPM.

My goal is to be able to provide API Bidding Updates (Mutates) for all the available bidding strategies,  by using the Google Ads API Python Client Library. Important Note: The only type of Campaigns that we are interested in are App Campaigns.

Example of failed request (and response) for setting MANUAL_CPC for a Campaign:

[2023-07-12 10:24:46 - INFO] Request
-------
Method: /google.ads.googleads.v14.services.CampaignService/MutateCampaigns
Host: googleads.googleapis.com
Headers: {
  "developer-token": "REDACTED",
  "login-customer-id": "9126245774",
  "x-goog-api-client": "gl-python/3.11.4 grpc/1.54.2 gax/2.11.0 gccl/21.2.0 pb/4.23.2",
  "x-goog-request-params": "customer_id=2371697191"
}
Request: customer_id: "2371697191"
operations {
  update_mask {
    paths: "resource_name"
    paths: "app_campaign_setting.bidding_strategy_goal_type"
    paths: "manual_cpc.enhanced_cpc_enabled"
  }
  update {
    resource_name: "customers/2371697191/campaigns/14304399031"
    app_campaign_setting {
      bidding_strategy_goal_type: OPTIMIZE_INSTALLS_TARGET_INSTALL_COST
    }
    manual_cpc {
      enhanced_cpc_enabled: true
    }
  }
}


Response
-------
Headers: {
  "google.ads.googleads.v14.errors.googleadsfailure-bin": "\nr\n\u0003\u0003\u0002\u00123The operation is not allowed for the given context.\u001a\f*\nMANUAL_CPC\"(\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006update\u0012\f\n\nmanual_cpc\u0012\u0016a3jdlHwU1x1MFIYrWhixDw",
  "grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid argument.\u001a\u0001\nDtype.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure\u0012\u0001\nr\n\u0003\u0003\u0002\u00123The operation is not allowed for the given context.\u001a\f*\nMANUAL_CPC\"(\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006update\u0012\f\n\nmanual_cpc\u0012\u0016a3jdlHwU1x1MFIYrWhixDw",
  "request-id": "a3jdlHwU1x1MFIYrWhixDw"
}
Fault: errors {
  error_code {
    context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT
  }
  message: "The operation is not allowed for the given context."
  trigger {
    string_value: "MANUAL_CPC"
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "update"
    }
    field_path_elements {
      field_name: "manual_cpc"
    }
  }
}
request_id: "a3jdlHwU1x1MFIYrWhixDw"


The error  "The operation is not allowed for the given context." is quite generic and doesn't really provide any useful information to understand why this operation is not allowed. The exact same error is raised for all the other Bidding Strategies attempted.

Thank you!

Adrian Lazar

unread,
Jul 12, 2023, 7:13:37 AM7/12/23
to Google Ads API and AdWords API Forum
To add to the above, here's what happens when I try to set TARGET_ROAS using MAXIMIZE_CONVERSION_VALUE:

[2023-07-12 11:10:55 - INFO] Request

-------
Method: /google.ads.googleads.v14.services.CampaignService/MutateCampaigns
Host: googleads.googleapis.com
Headers: {
  "developer-token": "REDACTED",
  "login-customer-id": "9126245774",
  "x-goog-api-client": "gl-python/3.11.4 grpc/1.54.2 gax/2.11.0 gccl/21.2.0 pb/4.23.2",
  "x-goog-request-params": "customer_id=2371697191"
}
Request: customer_id: "2371697191"
operations {
  update_mask {
    paths: "resource_name"
    paths: "app_campaign_setting.bidding_strategy_goal_type"
    paths: "maximize_conversion_value.target_roas"

  }
  update {
    resource_name: "customers/2371697191/campaigns/14304399031"
    app_campaign_setting {
      bidding_strategy_goal_type: OPTIMIZE_INSTALLS_TARGET_INSTALL_COST
    }
    maximize_conversion_value {
      target_roas: 1.6
    }
  }
}


Response
-------
Headers: {
  "google.ads.googleads.v14.errors.googleadsfailure-bin": "\n\u0001\n\u0003\u0003\u0002\u00123The operation is not allowed for the given context.\u001a\u001f*\u001dMULTIPLE(MULTIPLE_MOBILE_APP)\"F\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006update\u0012\u001b\n\u0019maximize_conversion_value\u0012\r\n\u000btarget_roas\u0012\u0016DbKcNtVnq1oOm8U_T8JyBA",
  "grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid argument.\u001a\u0002\nDtype.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure\u0012\u0001\n\u0001\n\u0003\u0003\u0002\u00123The operation is not allowed for the given context.\u001a\u001f*\u001dMULTIPLE(MULTIPLE_MOBILE_APP)\"F\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006update\u0012\u001b\n\u0019maximize_conversion_value\u0012\r\n\u000btarget_roas\u0012\u0016DbKcNtVnq1oOm8U_T8JyBA",
  "request-id": "DbKcNtVnq1oOm8U_T8JyBA"

}
Fault: errors {
  error_code {
    context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT
  }
  message: "The operation is not allowed for the given context."
  trigger {
    string_value: "MULTIPLE(MULTIPLE_MOBILE_APP)"

  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "update"
    }
    field_path_elements {
      field_name: "maximize_conversion_value"
    }
    field_path_elements {
      field_name: "target_roas"
    }
  }
}
request_id: "DbKcNtVnq1oOm8U_T8JyBA"

Google Ads API Forum Advisor

unread,
Jul 12, 2023, 12:20:11 PM7/12/23
to adr...@tempr.ai, adwor...@googlegroups.com

Hello,

Thanks for reaching out to the Google Ads API Team.

Upon checking your logs, your bidding_strategy_goal_type is OPTIMIZE_INSTALLS_TARGET_INSTALL_COST, please note when this is your goal type, your Bidding strategy should be target_cpa which is shown in this API documentation(https://developers.google.com/google-ads/api/docs/app-campaigns/create-campaign#focus_more_installs) when determining the focus of your campaign, this will also determine the values for specific settings as well as which features you can use.

Additionally, you may follow this documentation guide on how to create an App campaign (https://developers.google.com/google-ads/api/docs/app-campaigns/create-campaign). 

This message is in relation to case "ref:_00D1U1174p._5004Q2n6hwZ:ref"

Thanks,
 
Google Logo Google Ads API Team


Adrian Lazar

unread,
Jul 14, 2023, 8:43:47 AM7/14/23
to Google Ads API and AdWords API Forum
Hello, 

Thank you for your reply.

I do understand the connection between bidding_strategy_goal_type and bidding_strategy_type, hence why, as previously mentioned, I am able to make updates for TARGET_CPA and TARGET_ROAS. Even in the documentation links that you shared, these are the only two bidding strategies covered.

I am specifically looking for means of supporting bid updates, at Campaign level, (in whatever form) for the following bid strategies:
- MAXIMIZE_CONVERSION_VALUE
-  MANUAL_CPC
- PERCENT_CPC
- TARGET_CPM
- TARGET_SPEND

Additionally, please let me know if any of these bidding strategies do not permit bidding updates through the API so at least I have a better understanding of how things work.

Thank you

Google Ads API Forum Advisor

unread,
Jul 14, 2023, 10:10:48 AM7/14/23
to adr...@tempr.ai, adwor...@googlegroups.com
Hi Adrian,

Thank you for getting back to us.

Moving forward to your concern, since you want to know more about all the bidding strategy types, I suggest you check our documentation about Bidding. This guide describes everything you need to know to work with bidding strategies in the Google Ads API. In addition, you may also check the table in the Bidding Strategy Types which shows the Valid Contexts column indicates whether a given BiddingStrategyType and its matching bidding scheme can be used in the context of standard or portfolio strategies.

In addition, you may check the following errors below and the reason why the errors occur:
  • BiddingError.INVALID_ANONYMOUS_BIDDING_STRATEGY_TYPE - Using a portfolio-only bidding scheme in the context of a standard strategy.
  • BiddingStrategyError.BIDDING_STRATEGY_NOT_SUPPORTED - Using a standard-only bidding scheme in the context of a portfolio.

If you have any concerns, please let us know.

Reference links:

Adrian Lazar

unread,
Jul 28, 2023, 5:34:51 AM7/28/23
to Google Ads API and AdWords API Forum
Hello,

Thank you for getting back to me.

Before starting this conversation I actually spent plenty of time studying the entire documentation available regarding Bidding. I've also spent time looking at the GitHub public repo where there are coding examples on how to perform various operations. The reason why I felt compelled to start this conversation in the first place was because I just couldn't find the answers that I was looking for. 

It seems that I am getting closer though. 

Considering the fact that our only interest are App Campaigns could you please confirm that the only two bidding strategies that are available for us to use and manipulate are:
1) TARGET_ROAS
2) TARGET_CPA


Thank you for your support!

Google Ads API Forum Advisor

unread,
Jul 28, 2023, 9:17:40 AM7/28/23
to adr...@tempr.ai, adwor...@googlegroups.com

Hello Adrian,



Thank you for getting back to us.

Yes, the available bidding strategies for you to use and manipulate on an App campaign are TARGET_ROAS and TARGET_CPA. Please see our code example on Standard bidding strategies(via this link https://developers.google.com/google-ads/api/docs/campaigns/bidding/assign-strategies#standard_bidding_strategies) for more information. 

I hope this clarifies. Let us know if you have any additional questions. 

Reply all
Reply to author
Forward
0 new messages