Google Ads API (Python): How to remove target_cpa_micros on ad group level?

205 views
Skip to first unread message

Mat

unread,
Nov 4, 2020, 11:59:03 AM11/4/20
to AdWords API and Google Ads API Forum
Hi,

how can I remove a target_cpa_mircos from an ad_group?

If I just set the value to 0 it happens nothing (like: no change, no error message):

...
ad_group_service = google_ads_client.get_service("AdGroupService", version="v4")
ad_group_operation = google_ads_client.get_type("AdGroupOperation", version="v4")
ad_group = ad_group_operation.update
ad_group.resource_name = ad_group_resource_name
ad_group.target_cpa_micros.value = 0
fm = protobuf_helpers.field_mask(None, ad_group)
ad_group_operation.update_mask.CopyFrom(fm)
...

What's wrong?

Regards
Mat
...

Google Ads API Forum Advisor Prod

unread,
Nov 5, 2020, 1:10:23 AM11/5/20
to m...@keyword-experte.de, adwor...@googlegroups.com
Hi Mat,

If you are looking for a way to update your bids, you may refer to this guide as to how. If you wish to remove bids, you can set the field back to null.

Let me know if this helps.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2777tv:ref

Mat

unread,
Nov 5, 2020, 7:11:20 AM11/5/20
to AdWords API and Google Ads API Forum
Hi Peter,

thanks for the response - that sadly didn't help me at all.
As you might know, there is no "null" in Python but a "None". So I've tried all kind of stuff:

ad_group.target_cpa_micros.value = None
(Error: None has type NoneType, but expected one of: int, long)

ad_group.target_cpa_micros.value = 0
(no error, no change)

ad_group.target_cpa_micros.value = int()
(no error, no change)

ad_group.target_cpa_micros.value = ""
(Error: '' has type str, but expected one of: int, long)

And hell, even
ad_group.target_cpa_micros.value = "null"
(Error: 'null' has type str, but expected one of: int, long)

Trial an error only get you so far - would it be much to ask for one line of code (to work with the Python library) from your side?

Regards
Mat

Google Ads API Forum Advisor Prod

unread,
Nov 6, 2020, 2:04:48 AM11/6/20
to m...@keyword-experte.de, adwor...@googlegroups.com
Hi Mat,

Thank you for your follow up.

Since your concern is now more related on how to implement the bid updates using Python, I would recommend that you reach out to the Python client library owners instead as they are the more appropriate team to provide guidance.

You can reach them via their Github link. I hope this helps.

Mat

unread,
Nov 6, 2020, 6:02:37 AM11/6/20
to AdWords API and Google Ads API Forum
Hi Peter,

well, since there are already more than 20 unanswered and unassigned open issues over there, (including one 17 days old of myself), I figured that they might be quite shorthanded currently - maybe because of the v6 rollout.

So I thought that even if no one of the Google Ads API Team, then maybe someone of the community here already found a solution to my issue.

I've already checked the python protobuf section and tried some new approches like

ad_group.target_cpa_micros.Clear("value")
(no error, no change)

... but with no luck.

I'm beginning to suspect that the problem might not be this line of code but instead somewhere in the field_mask part:

fm = protobuf_helpers.field_mask(None, ad_group)
ad_group_operation.update_mask.CopyFrom(fm)

I've already googled and found a (3rd party?) "documentation" to the protobuf_helpers.field_mask, but still I can't see any issues there.

As it seems, as soon as the ad_group.target_cpa_micros.value ist empty, 0 or cleared, the field_name is missing in the field_mask and therefore no changes are made.
Maybe there's a bug in the protobuf_helper.
I'd like to see the source code of the protobuf_helpers.field_mask to check, how the two values are compared, but I couldn't find it. Do you have a link for me?

Regards
Mat


Google Ads API Forum Advisor Prod

unread,
Nov 10, 2020, 3:05:13 AM11/10/20
to m...@keyword-experte.de, adwor...@googlegroups.com
Hi Mat,

I am a colleague of Peter and let me provide support to your concern.

You may refer to this document about using field mask on Python client library. 

However, since this the concern is more on integration of Python client library, then please reach out to the author of the client library via this link as they are more equipped to provide support to this concern.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2777tv:ref
Reply all
Reply to author
Forward
0 new messages