GoogleAdsAPI: How to change individual keyword bids back to the ad group default bid?

53 views
Skip to first unread message

かねこ

unread,
Sep 30, 2019, 2:48:57 AM9/30/19
to AdWords API and Google Ads API Forum
I use Google Ads API Client Library for Java v2.


I edited individual keyword bid.

Long bidMicroAmount = Long.parseLong("1000000");
AdGroupCriterion adGroupCriterion =
   
AdGroupCriterion.newBuilder()
       
.setResourceName(ResourceNames.adGroupCriterion(customerId, adGroupId, criterionId))
       
.setCpcBidMicros(Int64Value.of(bidMicroAmount))
       
.build();
AdGroupCriterionOperation operation =
   
AdGroupCriterionOperation.newBuilder()
       
.setUpdate(adGroupCriterion)
       
.setUpdateMask(FieldMasks.allSetFieldsOf(adGroupCriterion))
       
.build();
MutateAdGroupCriteriaResponse response =
    adGroupCriterionServiceClient
.mutateAdGroupCriteria(
       
Long.toString(customerId), ImmutableList.of(operation));
It works.


Now, I need to change back to the ad group default bid.

First, I tried set bidMicroAmount to 0.

Long bidMicroAmount = Long.parseLong("0");

but it failed with INVALID_VALUE error.
  message: "The field's value is invalid."
  trigger: { int64_value: 0 }

Next, I tried clearCpcBidMicros() at build AdGroupCriterion.

AdGroupCriterion adGroupCriterion =
   
AdGroupCriterion.newBuilder()
       
.setResourceName(ResourceNames.adGroupCriterion(customerId, adGroupId, criterionId))
       
.clearCpcBidMicros()
       
.build();

It works without errors, bud no change keyword bid and bid source.

And I use setEffectiveCpcBidSource(BiddingSource.AD_GROUP) instead of clearCpcBidMicros(),
that works equally clearCpcBidMicros(), with no change.


How can I change back to ad group default bid ?

thanks:)

Google Ads API Forum Advisor Prod

unread,
Oct 1, 2019, 10:22:46 AM10/1/19
to yok...@gmail.com, adwor...@googlegroups.com
Hello,

Regret the delay. If you need to work with an existing object to update a few fields, you will need to create the FieldMask from the scratch as mentioned in this guide. You don’t need to use clearCpcBidMicros() to explicitly set the value to default. Please find the code snippet below for your reference: 

FieldMask fieldMask = FieldMask.newBuilder()
.addPaths("cpc_bid_micros")
.build();

I hope this helps. Please let me know if you have any further concerns.

Thanks,
Bharani, Google Ads API Team



ref:_00D1U1174p._5001UKLSzk:ref

かねこ

unread,
Oct 1, 2019, 7:47:49 PM10/1/19
to AdWords API and Google Ads API Forum
I could change cpc bid to default.
Many thanks for your helps!
Reply all
Reply to author
Forward
0 new messages