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();
  }
}

41 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. Great Article Cyber Security Projects projects for cse Networking Security Projects JavaScript Training in Chennai JavaScript Training in Chennai The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      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
  15. Cool script, very useful! is there a way to add labels to the ad groups you are pausing so it's easier to go back and look at them?

    ReplyDelete
  16. Students need not to worry about their assignments, term papers and dissertations because Assignment Australia is there to help you out and get you out of distress.

    ReplyDelete
  17. The ultimate goal of criminology assignment writing services is to provide Criminology Essay Writing Services and criminology coursework writing services since criminology assignments help service seekers lack time to complete their criminology research writing services.

    ReplyDelete
  18. There is a reliable Healthcare Assignment Writing Service that is very popular for students in search of healthcare coursework writing services and nursing essay writing help services.

    ReplyDelete
  19. The ultimate goal of entrepreneurship coursework writing services is to provide Entrepreneurship Writing Services and entrepreneurship essay writing services since entrepreneurship assignments writing service seekers lack time to complete their entrepreneurship term paper writing services.

    ReplyDelete
  20. How to write a literature review? Get Literature Review Help from UK Qualified PhD Expert Writers.

    ReplyDelete
  21. Get your ideal lit review Help from UK Qualified PhD Expert Writers.

    ReplyDelete
  22. Amazing blog! I found your website perfect for my needs. It contains wonderful and helpful posts. Keep up the good work. Thank you for this wonderful Blog! Check out the way to fix Dell Printer Error 1203. Lean how you can fix it at your own or feel free to call our experts on our toll-free numbers or visit our website to know more!

    ReplyDelete
  23. Thank you very much for giving space to us to express our feeling and thoughts about above information. I think you will keep updating and changing these information time to time if there is need to change. corporate auditing firms in India, auditing services in india , new company registration in delhi , top ca firms, gst registration for service provider in india, business advisory consulting services in india.

    ReplyDelete
  24. Hey there, I need an Statistics Homework Help expert to help me understand the topic of piecewise regression. In our lectures, the concept seemed very hard, and I could not understand it completely. I need someone who can explain to me in a simpler way that I can understand the topic. he/she should explain to me which is the best model, the best data before the model and how to fit the model using SPSS. If you can deliver quality work then you would be my official Statistics Assignment Help partner.

    ReplyDelete
  25. I don’t have time to look for another expert and therefore I am going to hire you with the hope that I will get qualityeconomics assignment help. .Being aneconomics homework help professor I expect that your solutions are first class. All I want to tell you is that if the solutions are not up to the mark I am going to cancel the project.


    ReplyDelete
  26. That is a huge number of students. Are they from the same country or different countries? I also want your math assignment help. I want to perform in my assignments and since this is what you have been doing for years, I believe you are the right person for me. Let me know how much you charge for your math homework help services.

    ReplyDelete
  27. Hello. Please check the task I have just sent and reply as soon as possible. I want an adjustment assignment done within a period of one week. I have worked with an Accounting Homework Help tutor from your team and therefore I know it’s possible to complete it within that period. Let me know the cost so that I can settle it now as your Accounting Assignment Help experts work on it.

    ReplyDelete
  28. My Assignment Help online is the hand-picked assignment help company offering most reliable Assignment Help service to students residing in Australia. Our team of writers are available 24×7 to provide professional academic writing service for assignments, essays, coursework and many more.

    ReplyDelete
  29. I am really happy to say it’s a thought-provoking post to read. I will deeply read your all info you will mention on your article it’s really helpful for me, thank you so much.
    Python assignment help

    ReplyDelete
  30. Online assignment writers are proficient scholarly writers who give assignment composing administrations to students with the goal that they can score better evaluations and gain from them the specialty of scholastic composition just as acquiring information from these specialists. Be that as it may, it is critical to know why online assignment writers are required in any case. There is a ton of tension on students to compose better assignments that can score better evaluations for them. Students don't see how to deal with the pressing factor and demonstrate their value in the academic field. myassignmenthelp

    ReplyDelete
  31. Wow, such an awesome blog you have written there and you and I get exactly what information I am looking for, in the third paragraph you put amazing effort to explain the theme of the content. As a content writer, I can understand efforts because when students ask me for programming assignment help,I do the same.

    ReplyDelete
  32. It was so hard. But I got a lot of help from your blog. 메이저놀이터 Please keep a lot of good articles in the future.

    ReplyDelete
  33. Are you feeling like your college assignment is so hard? if yes, then uaeassignmenthelp.com is one of the great places for UAE assignment writing services. we have a pretty good team who are available for 24x7 hrs and deliver top-quality assignment writing at cheesy prices.

    ReplyDelete