Showing posts with label delete. Show all posts
Showing posts with label delete. Show all posts

Thursday, November 22, 2012

Delete All Disapproved Ads in an Account

Again, another simple script that just focuses on account maintenance. Over time, large accounts might build up thousands of adgroups with ads that might be disapproved. Sometimes, it makes sense to remove those and then slowly build and deploy new creative (we will have a script to build new creative later). Hopefully this will work for you.

// Delete Ads That Are Disapproved
// Created By: Russ Savage
function main() {
  // Let's start by getting all of the ad that are disapproved
  var ad_iter =
  .withCondition("ApprovalStatus != APPROVED")

  // Then we will go through each one
  while (ad_iter.hasNext()) {
    var ad =;
    // now we delete the ad
    Logger.log("Deleteing ad: " + ad.getHeadline());

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.

* Pause Keywords With No Impressions All Time
* Version 1.1
* Changelog v1.1
*   - Updated for speed and added comments 
* Created By: Russ Savage
var TO_NOTIFY = "";
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")
  // 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 =;
    // 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) {
  // Now go through each one and pause them.
  for(var i in toPause) {
    //Or you could use toPause[i].remove(); to delete the keyword altogether
  // Sent an email to notify you of the changes
                    "AdWords Script Paused "+toPause.length+" Keywords.", 
                    "Your AdWords Script paused "+toPause.length+" keywords.");