Function createLabelIfNeeded

/* 
 * Function createLabelIfNeeded
 * Source: http://www.freeadwordsscripts.com/
 */

function main() { 
  createLabelIfNeeded("Test", "#ffffff");
}
function createLabelIfNeeded(name,color) {
  if(!AdWordsApp.labels().withCondition("Name = '"+name+"'").get().hasNext()) {
    Logger.log('Creating label: "'+name+'"');
    AdWordsApp.createLabel(name,"",color);
  } else {
    Logger.log('Label: "'+name+'" already exists.');
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *