Thursday, April 18, 2013

Pause or Enable Campaigns, Keywords or Ads on a Specific Date

UPDATE 2013-12-13: Added the ability to work on Ads as well.

I've seen some questions posted around the forums asking about enabling or pausing keywords on a given day. It is pretty simple to do using labels and scripts. The following script will run through your account and look for keywords labeled with "Pause on " or "Enable on " and perform that action. If you would like to just use dates, you can set the two prefix values to be empty strings (""). The format of the date is YYYY-MM-DD (2013-05-01).


* Pause or Enable Campaigns, Keywords or Ads on a Given Date
* Version 1.2
* Changelog v1.2 - Added ability to pause Campaigns
* Changelog v1.1 - Added ability to run on Ads
* Created By: Russ Savage
var ENTITY = 'Keyword'; //or Ad or Campaign
var PAUSE_PREFIX = "Pause on "; //look for labels "Pause on 2013-04-11"
var ENABLE_PREFIX = "Enable on "; //look for labels "Enable on 2013-04-11"

function main() {
  var todayStr = Utilities.formatDate(new Date(), AdWordsApp.currentAccount().getTimeZone(), "yyyy-MM-dd");
  var pauseStr = PAUSE_PREFIX+todayStr;
  var enableStr = ENABLE_PREFIX+todayStr;
  Logger.log("Looking for labels: " + [pauseStr,enableStr].join(' and '));
  var labelsArray = buildLabelArray(pauseStr,enableStr);
  if(labelsArray.length > 0) { 
    var labelsStr = "['" + labelsArray.join("','") + "']";
    var entityIter;
    if(ENTITY === 'Keyword') {
      entityIter = AdWordsApp.keywords().withCondition("LabelNames CONTAINS_ANY "+labelsStr).get();
    } else if(ENTITY === 'Ad') {
      entityIter ="LabelNames CONTAINS_ANY "+labelsStr).get();
    } else if(ENTITY === 'Campaign') {
      entityIter = AdWordsApp.campaigns().withCondition("LabelNames CONTAINS_ANY "+labelsStr).get();
    } else {
      throw 'Invaid ENTITY type. Should be Campaign, Keyword or Ad. ENTITY:'+ENTITY;
    while(entityIter.hasNext()) {
      var entity =;
      pauseEntity(entity, pauseStr);
      enableEntity(entity, enableStr);
//Helper function to build a list of labels in the account
function buildLabelArray(pauseStr,enableStr) {
  var labelsArray = [];
  try {
    var labelIter = AdWordsApp.labels().withCondition("Name IN ['"+pauseStr+"','"+enableStr+"']").get();
    while(labelIter.hasNext()) {
    return labelsArray;
  } catch(e) {
  return [];
//Helper function to pause entities
function pauseEntity(entity, pauseStr) {
  var labelIter = entity.labels().withCondition("Name = '"+pauseStr+"'").get();
  if(labelIter.hasNext()) {
//Helper function to enable entities
function enableEntity(entity, enableStr) {
  var labelIter = entity.labels().withCondition("Name = '"+enableStr+"'").get();
  if(labelIter.hasNext()) {


  1. This comment has been removed by the author.

  2. I couldn't get it to work. I have 6 campaigns running. I want them to stop on 8-22-19 and re-enable them back again on 8-27-19. I appreciate your help.

  3. If you are struggling hard with your film critique assignment, just write us a message saying, “Please write my movie critique” and this company will gladly do it at an affordable price.

  4. Online psychology paper writing service companies are very keen when it comes to Psychology Research Paper Services for students stuyding psychology studies in order for them to score straight A’s in their custom psychology research papers.

  5. The best place to find help with assignment help online service is AllAssignmentHelp.Com. if you want good quality malaysian assignment help,then i suggest you try AllAssignmentHelp service. We have well experienced and high quality assignment experts team which written best assignment for your academic career at affordable money.
    All Assignment Help My | assignment help online | help with assignment | essay writer

  6. Social science essay writing help has become very popular among students seeking Social Science Writing Services and social science coursework writing services.

  7. Accounting assignment writing services have become very popular for students studying finance & accounting coursework writing services as they engage the best online Accounting Writing Services.

  8. Get more than enough reasons to take expert help for the Business textbook solution manuals from CFS. As you may not be able to handle the bussiness queries, so to make it easier for you get expert help.

  9. Webroot is undoubtedly one of the most appreciated and renowned Antivirus programs developed and marketed by a private company in the USA. Webroot Secure is known as "Webroot SecureAnywhere." The product is renowned for removing viruses and restricting malicious links and sites to open on the device and thus it protects data and devices on a large scale.

    For more information visit site :-

  10. This is best done by the Geek Squad technicians by arriving at your doorstep at a mutually agreed scheduled time and convenience,or alternately, when you visit our Best Buy stores for anin-person technical resolution. Schedule Best Buy Geek Squad Appointment round-the-clock to assist you with their finest services at your time and location.Any specialist professional of the team in your area will contact you immediately, arrive at your doorstep and get the setup and installation done with a perfect demo to leave you with your device in the best of running condition.

    For more information visit site :- Geek Squad tech support

    Geek Squad appoinment

    Geek Squad tech support

  11. Roku is a streaming device, which is a reasonable roku activation and other Set-up Box. Roku is a bundle of amusement, where client can stream for boundless motion appears, web arrangement, news, animation and a lot more projects.