Category Archives: Google Ads Functions

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.');
  }
}

Function myLog

Instead of Logger.log you can use in test mode custom help function myLog(). After test Google Ads Script you need to only change value of variable writeLog.

/* 
 * Function myLog
 * Source: https://gscripts.eu/mylog/
 */

var writeLog = 1; // if not test mode, use 0 or something else
function main() { 
  myLog("Lorem Ipsum", writeLog);
}
function myLog(text, number){
   if (number == 1) {
    Logger.log(text);
   }
}