Python GoogleAdsClient update multiple keyword bids simultaneously

282 views
Skip to first unread message

Laurie McIntosh

unread,
Feb 10, 2022, 5:54:03 PM2/10/22
to Google Ads API and AdWords API Forum
Hi all,

I have several adgroups for which I need to daily update the max cpc at the keyword level.

I'd like to know how to do this efficiently.

Currently I'm updating at the adgroup level, but some of these campaigns are setup to have the keyword bid override the adgroup maxcpc value. So I need to grab the hundreds of keywords, determine what their current bid is and update it based on some criteria.

Doing these keywords one by one would blow out my quota each day, so looking for some details on how to batch them up to an adgroup level.

Anyone point me to some info. I've seen info for the older adwords module but not for the google.ads.googleads.client.GoogleAdsClient module.

Thanks in advance,

---=L

Google Ads API Forum Advisor

unread,
Feb 11, 2022, 9:18:17 AM2/11/22
to laurie....@mimeanalytics.com, adwor...@googlegroups.com
Hi Laurie,

Thank you for reaching out to Google Ads/AdWords API support. The Ads API encourages using reports instead of GET, version 10 took out GET from all services intentionally. You can use keyword_view report to get the bids set for all keywords. The Campaign report has access to any bidding strategy  no matter what the bidding strategy type is. The ad_group report can show which campaign an ad group belongs to.You can use these reports to just change just the keyword bids that fit for your use case.

Feel free to get back to us.

Regards,

Google Logo
Aryeh
Google Ads API Team
 



 

ref:_00D1U1174p._5004Q2W6GCQ:ref

Laurie McIntosh

unread,
Feb 13, 2022, 11:50:23 PM2/13/22
to Google Ads API and AdWords API Forum
>> You can use these reports to just change just the keyword bids that fit for your use case.

Awesome. How? I see how to run the report to get the values. How do I push the updated values back up?

Google Ads API Forum Advisor

unread,
Feb 14, 2022, 2:55:11 AM2/14/22
to laurie....@mimeanalytics.com, adwor...@googlegroups.com

Hi Laurie,

Thanks for getting back to us.

The ad_group_criterion.cpc_bid_micros value will change the Max CPC of the specific keyword. If you want to change the max CPC of the entire ad group, you can do this through the AdGroupService since that service handles changes to the ad group itself. You can also make use of AdGroupCriterionService that makes changes for the ad group criteria and not for the ad group as a whole.

Let us know if you have any further questions.

Regards,

Google Logo
Yasar
Google Ads API Team
 


ref:_00D1U1174p._5004Q2W6GCQ:ref

Laurie McIntosh

unread,
Feb 14, 2022, 2:27:58 PM2/14/22
to Google Ads API and AdWords API Forum

query = """
SELECT campaign.id, ad_group.id, ad_group_criterion.keyword.text, ad_group_criterion.criterion_id, ad_group_criterion.cpc_bid_micros
FROM keyword_view
WHERE campaign.id = 12345678
"""

search_request = client.get_type("SearchGoogleAdsStreamRequest")
search_request.customer_id = customer_id
search_request.query = query
stream = ga_service.search_stream(search_request)

for batch in stream:
     for row in batch.results:
         campaign = row.campaign
         ad_group = row.ad_group
         criterion = row.ad_group_criterion
         criterion.cpc_bid_micros = 20000


And get all of the current bids and update the stream cpc_bid_micros to, say 20000. What I'm missing is the way to take that set of criterion values and update them as a batch. I know how to do them one by one, but not as a batch.

Google Ads API Forum Advisor

unread,
Feb 15, 2022, 12:05:20 PM2/15/22
to laurie....@mimeanalytics.com, adwor...@googlegroups.com
Hi Laurie,

'keyword_view' gives you all the keywords that are at ad group level, you can use the adGroupCriterionService and change the bid_modifier field and you can change up to 10,000 criterion per request. A sample that modifies 1 keyword is update_keyword.py, but operations can have multiple operations in  the array. There's no need to use batch processing or  mutating resources if you are only updating some keywords.

Regards,

Google Logo
Aryeh
Google Ads API Team
 


ref:_00D1U1174p._5004Q2W6GCQ:ref

Laurie McIntosh

unread,
Feb 15, 2022, 10:33:42 PM2/15/22
to Google Ads API and AdWords API Forum
Perfect. Didn't realise it took a list as an operator. Many thanks for your help.
Reply all
Reply to author
Forward
0 new messages