Closed Rukeith closed 3 years ago
@Rukeith Here's the Python example, it's just not included in that set of docs. I'll see if we can get it added in. Thanks for pointing this out.
Hi, @BenRKarl thank you provide me this.
But how could I update bidding_strategy to MAXIMIZE_CONVERSION_VALUE
without target_roas?
Which like this.
Here are my example and output
def main(client, customer_id, campaign_id):
campaign_service = client.get_service("CampaignService", version="v5")
# Create campaign operation.
campaign_operation = client.get_type("CampaignOperation", version="v5")
campaign = campaign_operation.update
campaign.resource_name = campaign_service.campaign_path(
customer_id, campaign_id
)
campaign.maximize_conversion_value.CopyFrom(
self._client.get_type('MaximizeConversionValue'))
fm = protobuf_helpers.field_mask(None, campaign)
fm.paths.append("maximize_conversion_value")
campaign_operation.update_mask.CopyFrom(fm)
# Update the campaign.
try:
campaign_response = campaign_service.mutate_campaigns(
customer_id, [campaign_operation]
)
except google.ads.google_ads.errors.GoogleAdsException as ex:
print(
'Request with ID "%s" failed with status "%s" and includes the '
"following errors:" % (ex.request_id, ex.error.code().name)
)
for error in ex.failure.errors:
print('\tError with message "%s".' % error.message)
if error.location:
for field_path_element in error.location.field_path_elements:
print("\t\tOn field: %s" % field_path_element.field_name)
sys.exit(1)
print("Updated campaign %s." % campaign_response.results[0].resource_name)
Output
-------
Method: /google.ads.googleads.v6.services.CampaignService/MutateCampaigns
Host: googleads.googleapis.com:443
Headers: {
"developer-token": "REDACTED",
"login-customer-id": "xxxxxx",
"x-goog-api-client": "gl-python/3.8.8 grpc/1.35.0 gax/1.26.0 gapic/9.0.0",
"x-goog-request-params": "customer_id=xxxxxx"
}
Request: customer_id: "xxxxxx"
operations {
update {
resource_name: "customers/xxxxxx/campaigns/xxxxxxxx"
maximize_conversion_value {
}
}
update_mask {
paths: "resource_name"
paths: "maximize_conversion_value"
}
}
Response
-------
Headers: {
"google.ads.googleads.v6.errors.googleadsfailure-bin": "\nc\n\u0002@\u0003\u0012KThe field mask updated a field with subfields: 'maximize_conversion_value'.\"\u0010\u0012\u000e\n\noperations\u0018\u0000",
"grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid argument.\u001a\u0001\nCtype.googleapis.com/google.ads.googleads.v6.errors.GoogleAdsFailure\u0012e\nc\n\u0002@\u0003\u0012KThe field mask updated a field with subfields: 'maximize_conversion_value'.\"\u0010\u0012\u000e\n\noperations\u0018\u0000",
"request-id": "uFmHMdqL1WT6MDPCUVKYsg"
}
Fault: errors {
error_code {
field_mask_error: FIELD_HAS_SUBFIELDS
}
message: "The field mask updated a field with subfields: \'maximize_conversion_value\'."
location {
field_path_elements {
field_name: "operations"
index: 0
}
}
}
Sorry @BenRKarl Do you have any advice?
I found this document link.
Standard bidding strategies don't have python example. How could I update the campaign bidding strategy with standard bidding strategies?