Monday, November 19, 2012

Pause All Keywords With No Impressions

Let's start with a very simple script. This one will find all of the keywords in your account that has never had an impression, and pause (or delete if you see the comment below) that keyword so that it will not negatively impact your quality score. According to Google, the longer something sits in your account and stagnates, the greater the impact to your quality score. As a reader pointed out, the fourth bullet here seems to contradict this statement. This would be a great script to schedule every few months to make sure you are trimming all the dead weight from your accounts.

Thanks,
Russ
/*********************************************
* Pause Keywords With No Impressions All Time
* Version 1.1
* Changelog v1.1
*   - Updated for speed and added comments 
* Created By: Russ Savage
* FreeAdWordsScripts.com
**********************************************/
var TO_NOTIFY = "your_email@domain.com";
function main() {
  // Let's start by getting all of the keywords with no impressions
  var kwIter = AdWordsApp.keywords()
    .withCondition("Impressions = 0") // could be "Clicks = 0" also
    .forDateRange("ALL_TIME") // could use a specific date range like "20130101","20131231"
    .withCondition("Status = ENABLED")
    .withCondition("CampaignStatus = ENABLED")
    .withCondition("AdGroupStatus = ENABLED")
    .get();
 
  // It is much faster to store all the keywords you want to process
  // and then make the changes all at once. This takes advantage
  // of the batch processing behind the scenes.
  var toPause = [];
  while (kwIter.hasNext()) {
    var kw = kwIter.next();
    toPause.push(kw);
    // This is to make sure you see things during the preview
    // When you run it for real, you can remove this clause to
    // increase speed.
    if(AdWordsApp.getExecutionInfo().isPreview() &&
       AdWordsApp.getExecutionInfo().getRemainingTime() < 10) {
      break;
    }
  }
  
  // Now go through each one and pause them.
  for(var i in toPause) {
    toPause[i].pause();
    //Or you could use toPause[i].remove(); to delete the keyword altogether
  }
  
  // Sent an email to notify you of the changes
  MailApp.sendEmail(TO_NOTIFY, 
                    "AdWords Script Paused "+toPause.length+" Keywords.", 
                    "Your AdWords Script paused "+toPause.length+" keywords.");
}

3 comments:

  1. Although I can see the logic in this script isn't the flaw that if I added a keyword yesterday then it may not get an impression immediately but could within 30 days. If I'm always adding keywords then how can I be sure I'm turning off "old" ones?

    ReplyDelete
  2. That's true Robert, this script will have issues dealing with new keywords. I think you can fix it by using labels.

    For example, for new keywords, when you add them in adwords, give them a label of "NEW". Then, in the script above, add .withCondition("LabelNames CONTAINS_NONE ['NEW']") to the keyword selector logic.

    Now the issue is how to remove the "NEW" label after 30 days. I am currently working on a script that will manage labels so that you can tell how old an entity is. I will post a link here when i complete it. I have also added a feature request to the AdWords Scripts forum for accessing CreateDate which would make this much easier: https://developers.google.com/adwords/scripts/community?place=topic%2Fadwords-scripts%2FcoLUX4sLuQo%2Fdiscussion

    Thanks,
    Russ

    ReplyDelete