Change Campaigns Target-ROAS

483 views
Skip to first unread message

Michael Ladewig

unread,
Apr 3, 2019, 11:15:08 AM4/3/19
to AdWords API and Google Ads API Forum
Hey guys,

I'm trying to change the target-ROAS of a specific campaign with the following Python snippet:

campaign_service = google_ads_client.get_service('CampaignService', version='v1')
campaign_operation = google_ads_client.get_type('CampaignOperation', version='v1')
campaign = campaign_operation.update
campaign.resource_name = campaign_service.campaign_path(cid, '911450346')
campaign.target_roas.target_roas = 4.1
fm = protobuf_helpers.field_mask(None, campaign.target_roas)
campaign_operation.update_mask.CopyFrom(fm)
campaign_response = campaign_service.mutate_campaigns(cid, [campaign_operation])
print('Updated campaign %s.' % campaign_response.results[0].resource_name)


As result, I get the error:

 
  campaign.target_roas.target_roas = 4.1
AttributeError: Assignment not allowed to field "target_roas" in protocol message object.

Can anybody help me, changing the target-ROAS?

googleadsapi...@google.com

unread,
Apr 3, 2019, 5:41:58 PM4/3/19
to AdWords API and Google Ads API Forum
Hello Michael, 

Can you make sure that your campaign is meeting the eligibility requirements as mentioned in this help center article? It could be one of the reasons as to why the error is being triggered.

Thanks,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Michael Ladewig

unread,
Apr 4, 2019, 4:02:22 AM4/4/19
to AdWords API and Google Ads API Forum
Hello Bharani,

Conversion is configured and this campaign has 46 Conversions during the last 30 days. Are there any other Parameter, that have to match?

I changed the error-throwing command to:

campaign.target_roas.target_roas.value = 3.7

and the error changed to:

google.ads.google_ads.errors.GoogleAdsException: (<_Rendezvous of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "{"created":"@1554359684.563000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1036,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"
>, <_Rendezvous of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "{"created":"@1554359684.563000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1036,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"
>, errors {
  error_code {
    field_mask_error: FIELD_NOT_FOUND
  }
  message: "The field mask contained an invalid field: \'value\'."
  location {
    field_path_elements {
      field_name: "operations"
      index {
      }
    }
  }
}
, 'xPv4PaUFvAI-7k95cZzYDg')

while mutate_campaigns.

Thanks,
Michael

Michael Ladewig

unread,
Apr 4, 2019, 5:14:28 AM4/4/19
to AdWords API and Google Ads API Forum
As a additional information, i can read the campaigns target-ROAS via GoogleAdsService.

the requested field is campaign.target_roas.target_roas and ist returns 4.0 as a valid Value, as the campaign has a target-ROAS of 400%.

I think, my API-Call isn't correct, but the best example, i found, was update_campaign.py in the Python client examples.

googleadsapi...@google.com

unread,
Apr 5, 2019, 2:41:03 PM4/5/19
to lad...@exito.de, AdWords API and Google Ads API Forum
Hello Michael, 

Regret the delay. I was checking with the team regarding this. The FIELD_NOT_FOUND error is because the field mask is incorrect. You can also calculate this using fm = protobuf_helpers.field_mask(None, campaign) Please refer to our code sample as a reference. 

Can you try fixing the field mask and setting the value as campaign.target_roas.target_roas.value = 10.0? If you're facing an issue, could you share the request Id so I can check this internally?

Let me know if you are facing an issue.

Thanks,
Bharani, Google Ads API Team

Michael Ladewig

unread,
Apr 9, 2019, 3:20:01 AM4/9/19
to AdWords API and Google Ads API Forum
Hello Bharani,

thank you very much. That worked fine. To understand the point of field mask, to i only have to reference the resource, i want to mutate? In my case, it was "campaign". If i want to update an AdGroup, the field mask is fm = protobuf_helpers.field_mask(None, ad_group) ?

Thanks
Michael

googleadsapi...@google.com

unread,
Apr 9, 2019, 11:53:19 AM4/9/19
to lad...@exito.de, AdWords API and Google Ads API Forum
Hello Michael, 

That's right. Please refer to this code sample to update an Ad group.

Thanks,
Bharani, Google Ads API Team
Reply all
Reply to author
Forward
0 new messages