The Holiday Ads Post

Posted on October 6, 2014 in

A Script To Turn Your Holiday Ads On/Off

Holidays are great to spend with the family and friends, have a little extra time off, and make some more money! On the other hand… holidays are scheduling nightmares. The worst is when you have alternate hours and holiday specials that need to be switched on and off at certain times. Didn’t get your calendar reminder last year? Client or boss saw the wrong ads up when the ads the specials were over? Yeah, we’ve all had to dance a little more to enjoy our extra time off. Well, this time, I’ve got the script you need to rest easy.

This is actually fairly simple, and I’ll walk you through what you need to do. The script is written to be extremely simple.

The Scripts

The script starts by looking for ads with the label “Holiday”. Of course, in order to switch on ads you’ll want to flip on after the holidays, you’ll want to add the script a second time for when to pause the “Holiday” ads. You’ll need to do this twice for the other non-holiday ads with a label, such as “Non-Holiday”. Note that one says pause and the other says enable. I’ve added all four versions so you’ll just need to copy-paste, add your labels, and set schedules.

Holiday On

function main() {
 var adSelector = AdWordsApp
     .ads()     
     .withCondition('LabelNames = "Holiday"');
 var adIterator = adSelector.get();
 while (adIterator.hasNext()) {
   var ad = adIterator.next();
     ad.enable();
}

Holiday Off

function main() {
 var adSelector = AdWordsApp
     .ads()     
     .withCondition('LabelNames = "Holiday"');
 var adIterator = adSelector.get();
 while (adIterator.hasNext()) {
   var ad = adIterator.next();
     ad.pause();
}

Non-Holiday On

function main() {
 var adSelector = AdWordsApp
     .ads()     
     .withCondition('LabelNames = "Non-Holiday"');
 var adIterator = adSelector.get();
 while (adIterator.hasNext()) {
   var ad = adIterator.next();
     ad.enable();
}

Non-Holiday Off

function main() {
 var adSelector = AdWordsApp
     .ads()     
     .withCondition('LabelNames = "Non-Holiday"');
 var adIterator = adSelector.get();
 while (adIterator.hasNext()) {
   var ad = adIterator.next();
     ad.pause();
}

Final Note

As with any script, I recommend testing a couple times to make sure it’s right. Also, since Google may run the script from different time zones, Nathan Byloff’s solution will automatically detect that and run the script from your account’s time zone settings.

By Kevin Adams

Kevin Adams has been doing PPC since 2004. He has managed many accounts from local service companies to large mortgage companies. His primary proficiencies are Google AdWords, Google Analytics, and Bing Ads. He continually stays up-to-date on the latest tricks, tools and trends provided by the search engines. If there is one thing that Kevin excels at most is making his clients money with Pay-per-Click advertising.

  • Frederick Vallaeys

    Hi Kevin,

    Thanks for contributing some sample scripts to the world, I’m a script writer too and once in a while I find myself scripting something that could have been more easily done with a simple AdWords Automated Rule. I think the example here is a good one for an automated rule because the ads are turned on and off just once. 

    Looking forward to seeing more of your scripts!
    Frederick

  • KevinAdams

    Frederick Vallaeys thank you. i’ve got a couple more scripts ready. i must admit i was
    working on this blog and halfway through realized an automated rule
    would do the same trick. but i was too excited about having a working
    script! still, i intend on using this one as a base to make more complex
    ones in the future.