Wednesday, November 21, 2012

Pause AdGroups With No Active Keywords

This is a quick script to pause all the AdGroups with no active keywords in them. Not sure if this is super useful, but for large accounts, it might help identify AdGroups you can get rid of.

Thanks,
Russ

/*********************************************
* Pause AdGroups With No Active Keywords
* Version 1.1
* Changelog v1.1
*   - Updated for speed and added comments 
* Created By: Russ Savage
* FreeAdWordsScripts.com
**********************************************/
function main() {
  // Let's start by getting all of the active AdGroups
  var agIter = AdWordsApp.adGroups()
    .withCondition('CampaignStatus = ENABLED')
    .withCondition('Status = ENABLED')
    .get();
 
  // It is faster to store them and process them all at once later
  var toPause = [];
  // Then we will go through each one
  while(agIter.hasNext()) {
    var ag = agIter.next();
    //get all the keywords that are enabled
    var kwIter = ag.keywords()
      .withCondition("Status = ENABLED")
      .get();
    
    //If .hasNext() is true, there is at least 1 kw in the AdGroup
    var hasKw = kwIter.hasNext(); 
    if(!hasKw) {
      toPause.push(ag);
    }
  }
  
  // Now we process them all at once to take advantage of batch processing
  for(var i in toPause) {
    toPause[i].pause();
  }
}

18 comments:

  1. This rule seems to time out every time? Any idea how I would manipulate this script to only search within ACTIVE campaigns? I believe it is timing out because I have a lot of deleted and paused campaigns.

    Thanks

    ReplyDelete
    Replies
    1. I'm assuming you have to add 'isEnabled()' in there somewhere.

      Delete
  2. Yeah it's easy to update. Instead of the line:

    var ag_iter = AdWordsApp.adGroups().get();

    Just use the following:

    var ag_iter = AdWordsApp.adGroups().withCondition("Status = ENABLED").get();

    Let me know if that works for you.

    Thanks,
    Russ

    ReplyDelete
  3. Hi! Is there a way to make sure that you keep DSA campaigns be excluded from this? I'm running into an issue where this script pauses all ad groups in my DSA campaign.

    ReplyDelete
  4. Thanks for sharing this post. Online assignment help from students assignment help.

    ReplyDelete
  5. Facing a deadline for finishing the essay? Well, your anxieties end here. We have with us a team of electrical assignment writing service and psychology assignment help for australia students who can solve all your writing issues so that you score high grades in your essay assignment.

    ReplyDelete
  6. All searches begin with a keyword or keyword phrase and if we want to have our blog read or our website found we must anticipate what words or phrases they will use in their search query.ppc keyword wrapper

    ReplyDelete
  7. According to reports of survey, it is confirmed now that three out of every four student seek online assignment help from professionals in Australia. It also indicate that students who avail assignment help for their assignment or homework from professionals improve their grade by 20% than those students, who do not take any help. If you are stuck with your research projects, essays, case studies, business reports or need Urgent Assignment Help, then myassignmenthelp is the place to be.

    ReplyDelete
  8. Canon Pixma MG2522 SetupDriver, Software, Download. Meet the PIXMA MG2522, a straightforward printer for your home printing needs.The PIXMA MG2522 makes it simple to.

    ReplyDelete
  9. Since modernization hit our nation hard, individuals are moving into getting things like a printer introduced at their homes. It is regular to confront little issues while working it. In this way, don't stress in the event that you are confronting inconveniences while working your Epson Printer. visit -- Printer is in an error state

    ReplyDelete
  10. I like this blog but I do not like to download this script because Maybe it is harmful to my working and I have lost the position of my keywords.
    coursework writing service

    ReplyDelete
  11. It is undisputed that Computer Science Writing Services pose challenges for students because preparation takes into consideration a lot of details needed for Computer Science Case Study Writing Services and in-depth knowledge on the topic in order to come up with award winning Computer Science Coursework Writing Services.

    ReplyDelete
  12. Social science coursework writing services are essential and it has become very popular for those seeking social science research paper writing services since most of them seek Social Science Writing Services.

    ReplyDelete
  13. Students find Human Resource Writing Services as being of great assistance since they are able to complete their human resource assignment writing services and human resource research paper writing services on time.

    ReplyDelete
  14. Very energetic blog, I liked that a lot. Will there be a part 2?

    Super Screenshot

    ReplyDelete