Monday, November 26, 2012

Update Ads for the New Year

This is a companion to one of my earlier posts about updating your keywords for the new year.  You can easily run through each ad you have and update them all for the new year using the script below.  It will also pause the old ad as well, making sure your staying relevant to your customers.  You should schedule this to run every year on January 1st if your advertising relies heavily on dated traffic.

Thanks,
Russ

//-----------------------------------
// Update Ads for 2012
// Created By: Russ Savage
// FreeAdWordsScripts.com
//-----------------------------------
function main() {
  var OLD_YEAR = "2011";
  var NEW_YEAR = "2012";
  //You probably shouldn't update destination urls unless you know what you are doing.
  var FIELDS_CONTAINING_YEAR = ["Headline","Description1",
                                "Description2","DisplayUrl"
                                /*,"DestinationUrl"*/
                               ];
  
  for(i in FIELDS_CONTAINING_YEAR) {
    var field_iter = AdWordsApp.ads()
        .withCondition(FIELDS_CONTAINING_YEAR[i] + " CONTAINS " + OLD_YEAR)
        .withCondition("Status = ENABLED")
        .get();
    
    _iterateThroughAds(field_iter);
  }

  //---------------
  // Private Helper Functions
  //---------------  
  function _iterateThroughAds(ad_iter) {
    while (ad_iter.hasNext()) {
      var ad = ad_iter.next();
      var ag = ad.getAdGroup();
      _createNewAdFromOldAd(ag,ad);
    }
  }
  
  function _createNewAdFromOldAd(adgroup, old_ad) {
    //get the updated ad texts replacing all the old years with the new years
    var new_headline = old_ad.getHeadline().replace(OLD_YEAR,NEW_YEAR);
    var new_desc1 = old_ad.getDescription1().replace(OLD_YEAR,NEW_YEAR);
    var new_desc2 = old_ad.getDescription2().replace(OLD_YEAR,NEW_YEAR);
    var new_display_url = old_ad.getDisplayUrl().replace(OLD_YEAR,NEW_YEAR);
    var new_dest_url = old_ad.getDestinationUrl();/*.replace(OLD_YEAR,NEW_YEAR);*/
    
    //now create the new ad and pause the old one.
    adgroup.createTextAd(new_headline,new_desc1,new_desc2,new_display_url,new_dest_url);
    old_ad.pause();
  }
}

31 comments:

  1. Yes, I can show you how to write an essay about yourself. Just have a peek here https://justdomyhomework.com/blog/essay-about-yourself

    ReplyDelete
  2. Psychology Coursework Writing Services has become a significant challenge owing to the complexity of Psychology Research Writing Services and in other cases lack of time and knowledge needed to prepare Online Psychology Assignment Writing Services .

    ReplyDelete
  3. Engineering assignment writing services are essential for college & university engineering research paper services seekers and Engineering Writing Services.

    ReplyDelete




  4. Wonderful information! I found amazing information on the blogs i suggest everyone to follow the links below to get download files from this website.



    https://apkfasak.com/fmwhatsapp-apk/
    https://apkfasak.com/gb-whatsapp-apk/




    ReplyDelete
  5. Nice post. I learn something totally new and challenging on websites I stumble upon every day. It's always useful to read through articles from other authors and practice something from other sites.also try this WhatsApp Plus Apk.

    ReplyDelete
  6. This is pretty informative. You can also check this messaging app mod that I found :

    https://flosshype.com/fmwhatsapp/

    ReplyDelete
  7. Download thoptv for pc download – Latest version – Free for Android and watch the latest films and tv shows for free! Enjoy unlimited streaming now in this awesome app!

    ReplyDelete
  8. It is important for neurobiology coursework writing help seekers to find the best Neurobiology Writing Services from a reputable neurobiology research paper writing service provider for their custom neurobiology essay writing services.

    ReplyDelete

  9. It's no wonder that in recent whatsapp plus became a huge part of our lives. It's conveyears nient quick and easy to use.

    ReplyDelete
  10. You can also visit ThopTV app download if you want to know everything about tech website and visit this site for getting information in Hindi You can also visit HdMoviesmaza if you want to know everything in Hindi

    ReplyDelete
  11. It is important for business management assignment help seekers to find the best Business Management Writing Services from a reputable business management paper writing service provider for their custom business management essay services.

    ReplyDelete
  12. Thanks for sharing this post.It is very informative and helpful.

    Sydney Brooke Simpson
    Jimmy Graham
    Bhgwalmartoffer

    ReplyDelete
  13. This strategy is the best because through this, many people will enjoy a good business through advertising and now they will get benefits. This update is very useful for them. Masters dissertation writing service.

    ReplyDelete
  14. Did you know that you can easily view the contents of your phone on your TV without a cable? With a screen mirror app you can easily do the screen mirroring from Android to TV. Check out www.screenmirroring.me to find out more.

    ReplyDelete
  15. I will impart to you the most recent Android applications and games with direct download from ruler mod apk on the web, where everybody can get the applications and games with the best modules.

    ReplyDelete
  16. People walk out of their houses on their phones, they drive while checking their emails, and walk down the street while texting someone
    AOL mail login
    grand canyon university portal

    ReplyDelete
  17. you can learn here the most amazing things about mobile app on pc. telechargerpourpc

    ReplyDelete
  18. "This is a very nice article and information by the admin… i like it.. keep sharing information like it.. will visit your site again for such kind of articlesDeskScapes Crack"

    ReplyDelete
  19. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates. I've been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates. coke and popcorn

    ReplyDelete
  20. The finest edubirdie site will never leave you without help. Hundreds of qualified writers will write you an essay on all the topics you just wish and will do their job on time. I advise everyone to order.

    ReplyDelete
  21. nice article!! Thanks for this wonderful content!!
    my site: ultra gamers and Interesting321

    ReplyDelete
  22. hello guys check super fast result here
    Lottery Sambad



    hello guys check super fast result here
    lotterysambadindia.com

    nice post love it Dhankesari Result

    ReplyDelete
  23. i love your work and i daily visit your site for update if you finding satta king then check my site :satta-result.org and check Gali Result

    ReplyDelete