Script for increasing max CPC bid for custom labels

110 views
Skip to first unread message

Lars

unread,
Sep 28, 2023, 7:53:20 AM9/28/23
to Google Ads Scripts Forum
Hey Google Ads Scripts Forum,

I have 2 questions that I hope you can help me with:

1)
I just setup the script below to automatically increase our Max CPC for products with the custom label value = x in our shopping campaigns.

function main() {
  var shoppingCampaignSelector = AdWordsApp.shoppingCampaigns();
 
  var shoppingCampaignIterator = shoppingCampaignSelector.get();
  while (shoppingCampaignIterator.hasNext()) {
    var shoppingCampaign = shoppingCampaignIterator.next();

    var shoppingAdGroups = shoppingCampaign.adGroups();
   
    var shoppingAdGroupsIterator = shoppingAdGroups.get();
    while(shoppingAdGroupsIterator.hasNext()){
      var shoppingAdGroup = shoppingAdGroupsIterator.next();
     
      var pgs = shoppingAdGroup.productGroups().get();
      while(pgs.hasNext()){
        var pg = pgs.next();
        Logger.log(pg.getDimension());
       
        if (pg.getDimension() == 'CUSTOM_LABEL'){ //if the product dimension is a custom label
          Logger.log("Custom Label: %s",pg.asCustomLabel().getValue());
         
          if (pg.asCustomLabel().getValue() == 'x'){ //custom label is x
            pg.asItemId().setMaxCpc(pg.asItemId().getMaxCpc()*1.50); //increases or decreases the bid by the multiplier
            Logger.log("Changed CPC to %s",pg.asItemId().getMaxCpc());
          }
          else if (pg.asCustomLabel().getValue() == 'y'){
            pg.asItemId().setMaxCpc(pg.asItemId().getMaxCpc()*0.80); //increases or decreases the bid by the multiplier
            Logger.log("Changed CPC to %s",pg.asItemId().getMaxCpc());
          }
        }
      }
    }
  }
}

I just realized that this script doesn't work as it is ment to. My plan was to run it once a day, so that it automatically increases the bids for new products where we have added the custom label = x in a Google supplemental feed. But that way it also keeps on increasing the bids for the products that already have the custom label value x. The bids should only be increased once for all products with custom label x.

Can I somehow use the max CPC for the "Everything else" products (the other products in this product group) in this line (23):
pg.asItemId().setMaxCpc(pg.asItemId().getMaxCpc()*1.50);

If I could do that, then the script will not keep on increasing the bids more and more everytime it runs, because the max CPC for "Everything else" stays the same :-)

2) 
The script is setup to run on a single Google Ads account. Can I modify the script to run on a MCC account so that I only have to maintain the script in one place? It should probably use the executeInParallel method (we have about 20 different Google Ads accounts).


My biggest concern is to fix the first issue, but if you could also help me with the second one that would be really great.

Thank you.

Lars

unread,
Sep 28, 2023, 7:53:23 AM9/28/23
to Google Ads Scripts Forum
Hi Ads Scripts Support Team,
Can I somehow use the max CPC for the "Everything else" products (all the other product in the same product group) in this line (23):

Lars

unread,
Sep 29, 2023, 4:19:40 AM9/29/23
to Google Ads Scripts Forum
Hi again,

regarding this: 

Can I somehow use the max CPC for the "Everything else" products (the other products in this product group) in this line (23):
pg.asItemId().setMaxCpc(pg.asItemId().getMaxCpc()*1.50);

I am referring to this:

Product group.png

Thanks!

Eric Torres

unread,
Sep 29, 2023, 8:34:14 AM9/29/23
to Lars via Google Ads Scripts Forum
Automatic 

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/7d3107aa-77f0-4735-be13-41cdc71c8d14n%40googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
Sep 29, 2023, 10:47:16 AM9/29/23
to adwords...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads Scripts support team.

I see that you have already raised this concern on another thread with the subject “Script for increasing max CPC bid for custom labels”', and we have already responded there for this issue. To avoid multiple threads on the same issue, please take a look at that thread and continue the discussion on the same for further updates on the issue.
 
This message is in relation to case "ref:_00D1U1174p._5004Q2p2Ojl:ref"

Thanks,
 
Google Logo Google Ads Scripts Team


Lars

unread,
Oct 3, 2023, 6:49:35 AM10/3/23
to Google Ads Scripts Forum
Automatic?
Reply all
Reply to author
Forward
0 new messages