Need to develop a script to have a cap on MaxCpc auto bidding - can you help please?

17 views
Skip to first unread message

Dortech Direct

unread,
Jun 5, 2019, 3:34:53 AM6/5/19
to Google Apps Script Community
Hi,

I have a script that automatically bids up high Impression production, with no clicks, by 10% increments each day, until such a time that someone clicks on that product. However I need to implement a control/cap on this and was wondering if anyone has anything that would work with this scenario. My base code is as follows:

function main() {
 
  var productGroups = AdsApp.productGroups() 
  .withCondition("Clicks = 0") 
  .withCondition("Impressions > 500")
  .forDateRange("ALL_TIME")
  .get();
   while(productGroups.hasNext()){
 var productGroup = productGroups.next();
  var currentMaxCpc = productGroup.getMaxCpc();
  productGroup.setMaxCpc( currentMaxCpc * 1.05 );
  }                           
}

ideally i'd like to exclude any products that have a MaxCpc =/> to £2.80.

Any thoughts would be appreciated.

Many Thanks,

James

Reno Blair

unread,
Jun 5, 2019, 11:12:14 AM6/5/19
to google-apps-sc...@googlegroups.com
I'm not familar with Google Ads or AdsApp, but couldn't you just add a condition before setting the max cpc?

function main() {
var cpcLimit = 2.8;
...
var currentMaxCpc = productGroup.getMaxCpc();
if (currentMaxCpc < cpcLimit) productGroup.setMaxCpc(currentMaxCpc * 1.05);

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/6694719d-2846-4a10-ad62-415059b79767%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Reno Blair
Educational Technology Services​
Reply all
Reply to author
Forward
0 new messages