Adwords Scripts Scheduling Script

7 Aaron Falloon

PPC Drawing

Anyone that has ever used Adwords Scripts will know the awesome benefits they can bring to an account’s performance and time they save. As sad as it sounds, they’re also be pretty fun to create.

However, one gripe I do have with them is the scheduling restrictions Adwords put on running them. As it stands, Account Managers are only able to schedule scripts to run either once, hourly, daily, weekly or monthly.

In most cases these options do the job, but what if you wanted a script to run on particular weekdays but not on others? Gravytrain have created a Adwords Script that schedules other Adwords Scripts to run.

Here’s a few pointers just so that you can start using it straight away…

  • Just list the days that you want your script to run within the weekdaysToRun array. E.g. if you want the script to run on weekends only, write ["Saturday", "Sunday"]
  • Insert the code / script you want to run on particular days where it indicates
  • Set the script to run Daily – your code will only run on days that you have selected

The code’s below – make sure you let us know how you’ve used the script in the comments section.

 

// This Adwords Scripts was created by Gravytrain Ltd. for public use.
// To find out more about Gravytrain visit https://www.gravytrain.co.uk/

function main() {

  // SELECT WHICH DAYS TO RUN SCRIPT
  // ENCLOSE IN " MARKS AND SEPERATE WITH COMMA
  var weekdaysToRun = ["Saturday", "Wednesday"];

  // MAPPING BETWEEN WEEKDAY AND JAVASCRIPT RETURN
  var weekday = new Array(7);
  weekday[0]= "Sunday";
  weekday[1] = "Monday";
  weekday[2] = "Tuesday";
  weekday[3] = "Wednesday";
  weekday[4] = "Thursday";
  weekday[5] = "Friday";
  weekday[6] = "Saturday";

  // GETTING TODAY'S WEEKDAY
  var date = new Date();
  var todaysWeekday = weekday[date.getDay()];

  // CHECK IF TODAY'S WEEKDAY MATCHES ANY OF THE WEEKDAYS SELECTED TO RUN
  if (weekdaysToRun.indexOf(todaysWeekday) >= 0) {

    // INSERT CODE TO RUN

  } else {
    // LOGS THAT SCRIPT DOESN'T RUN ON THIS DAY
    Logger.log("Today is " + todaysWeekday + " - no code to run.");
  }
}

To learn more about our PPC team, Click Here.