To help further our knowledge, our team recently started coming together for bi-weekly “Incubator” sessions, where we work together to tackle large-scale problems in our Paid Media accounts. The great part about the meetings is that it gets us all focused on one issue. The issue is defined by the Biddable Manager on the account, and all team members, whether familiar with the account or not, pitch in to come up with solutions.
The first issue we tackled seemed quite relevant to what many businesses struggle with in their accounts today – the scheduling of ad copy – so I thought sharing was necessary.
To give some back story, the issue we were trying to solve was for a non-traditional school, where we run paid search ads to promote new courses and workshops available on site. The school employs a number of instructors and holds a number of workshops and courses scattered throughout the year, all of which are searchable in Google. To create a personalized message based on the user search, our team had multiple ads running using specified dates - for example, "Register Before ___ to Reserve Your Seat!"
The trick with this strategy is that we had to pause and enable these ads manually – each day executing a search in AdWords for any ad copy that showed a course was ending. This was taking a significant amount of time for our Biddable Manager, because we did not have a way to automate specific ads in an AdWords to pause or enable on a given date (like with sitelinks). Pausing and enabling can be done at the campaign level in AdWords or at the ad level through third-party tools like DoubleClick Search, but not in the AdWords engine, which most businesses use to manage their accounts.
To solve this issue, our team scoured the Internet and pieced together an AdWords Script from multiple sources that runs off labels, allowing our team to pause or enable ads based on dates within the given label. Now, with our new AdWords Script, these ads automatically pause on the last day to register, as stated in the ad copy and in the label. Overall, this new AdWords Script saved our team 6-10 hours per month of manual account updates. Across other accounts, the script has saved numerous hours – making our team and our client accounts more efficient.
This is just one use case for the Script. Since its development, it has also been applied to our e-commerce businesses during sales or promotions, when the goal is to pause or enable ads on certain dates without having to create a separate campaign. Once the Script is added and tested, it runs smoothly without the need for reapplication. Another great feature of the Script - once the ads are paused or enabled, the label is removed notifying our team that the action has been completed. Want to see if you have any more upcoming promos? Just search for labels in your account - if you don't have any labels in the given format, nothing else is scheduled to run and you can continue running evergreen ad copy or start thinking of new promotions to run.
How to Test and Activate the Script:
  1. Create ad copy using specific dates. Include at least one ad copy version that uses today’s date and make sure that the ad is enabled once you upload through Editor (and then to the engine), even if the campaign or adgroup is paused.
  2. Once your ads are created, label your ads in bulk with the action you want the Script to take, knowing it will run daily. Keep in mind that this format must be used for the ad labels: Pause on YYYY-MM-DD or Enable on YYYY-MM-DD. For your test ad, label with “Pause” using today’s date. Tip: To label multiple ads quickly, use Excel and a formula that pulls the date from the ad copy and puts it in to a separate cell, which you can then upload to Editor in the Label column attached to your ads.
  3. Once all the ads are labeled, navigate to the AdWords engine, go to Bulk Operations on the left-hand menu and click “Create and Manage Scripts” under the “Scripts” heading.

    johnstone-image1
  4. From here, click the red +Script button and add the following Script.

    var ENTITY = 'Ad'; //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 = AdWordsApp.ads().withCondition("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 = entityIter.next();
          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()) {
          labelsArray.push(labelIter.next().getName());
        }
        return labelsArray;
      } catch(e) {
        Logger.log(e);
      }
      return [];
    }
      
    //Helper function to pause entities
    function pauseEntity(entity, pauseStr) {
      var labelIter = entity.labels().withCondition("Name = '"+pauseStr+"'").get();
      if(labelIter.hasNext()) {
        entity.pause();
        entity.removeLabel(pauseStr);
      }
    }
      
    //Helper function to enable entities
    function enableEntity(entity, enableStr) {
      var labelIter = entity.labels().withCondition("Name = '"+enableStr+"'").get();
      if(labelIter.hasNext()) {
        entity.enable();
        entity.removeLabel(enableStr);
      }
    }
    
  5. After your Script is implemented, click “Preview”. If the Script is working correctly, you should see that you ad labeled to pause on today’s date, will show as paused in the preview. If you see this, activate your Script by clicking “Save” and specify how often you want it to run. For our purposes, our team runs the Script daily at 1 AM.
Have you used any new AdWords Scripts lately? If so, feel free to leave comments and questions in the discussion below.