AdWords
3.6K members online now
3.6K members online now
Improve your AdWords performance and boost your ROI, CTR, and Quality Score
Guide Me
star_border
Reply

Scripts to boost CPA

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there

 

hey I'm trying to make this script run but only with campaigns labeled as "BOOSTED" but something is missing because every time I preview it...it affects campaigns even if those are not labeled as BOOSTED..

 

What corrections need to be done?

 

function main() {

  //For keywords with less than $5 CPC, let's pump those bids up by 35%
  var AMAZING_COST_PER_CONV = 15;
  var AMAZING_BID_INCREASE_AMOUNT = .35;
 
  //For keywords with between $5 and $8 CPCs, we will only increase the bids by 20%
  var GREAT_COST_PER_CONV = 30;
  var GREAT_BID_INCREASE_AMOUNT = .20;
  var LABEL = "BOOSTED";
 
 
  var camp_iter = (LABEL=="")? AdWordsApp.campaigns().get() :
                      AdWordsApp.campaigns()
                      .withCondition("LabelNames CONTAINS_ANY ['"+LABEL+"']")
                      .withCondition('CampaignStatus = ENABLED')
                      .get();     
  var kw_iter = AdWordsApp.keywords().withCondition('AdGroupStatus = ENABLED')
    .withCondition('Status = ENABLED')
     .get();
  while(camp_iter.hasNext()) {
    var camp = camp_iter.next();
 
    while(kw_iter.hasNext()) {
    var kw = kw_iter.next();
    var kw_stats = kw.getStatsFor("LAST_30_DAYS");
    var cost = kw_stats.getCost();
    var conversions = kw_stats.getConversions();
    if(conversions > 0) {
      var cost_per_conversion = (cost/(conversions*1.0));
      
      if(cost_per_conversion <= AMAZING_COST_PER_CONV) {
        kw.setMaxCpc(kw.getMaxCpc() * (1+AMAZING_BID_INCREASE_AMOUNT));
      }
      else if(cost_per_conversion <= GREAT_COST_PER_CONV) {
        kw.setMaxCpc(kw.getMaxCpc() * (1+GREAT_BID_INCREASE_AMOUNT));
      }
    }else{
      //no conversions on this keyword
      //we will deal with that later
      continue;
    }
  }
 

      continue;
    }
  }

1 Expert replyverified_user

Re: Scripts to boost CPA

Top Contributor
# 2
Top Contributor

Hi @Adstk I can't see anything obviously wrong with the code (I'm not in a position to test it right now).  As I'm sure you know, the key part is the line beginning var camp_iter =... and that does look as though it should select the second case when LABEL isn't empty.

 

I'd do the normal debugging process of echoing out everything involved (Logger.log).  Test LABEL by logging it out, test camp_iter by logging it out, etc.  If it still looks good, try using the selector without putting it into a var.  I'll try and test later today, but please poke me if I don't reply.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits