Sunday, October 20, 2013

Use GDrive To Load A Single AdWords Script Into Multiple Accounts

One of the downsides to using AdWords Scripts is that you need to log into each account and set up the script. For most people, that isn't a problem the first few times. But as you start seeing the value of some of these scripts, there might be a set of them that you want to put in all your accounts. Setting them up is fine, until you find a bug in your code and have to go in and update all 20 copies of the script in each account.

Well in this post, I put together a simple way to keep a single copy of your script and load it into any number of AdWords accounts. Then, if you ever have a change to make, you can update a single version of the script and all the accounts will instantly start using the new code.

The code for this consists of two parts. The first snippet of code is the generic code that you need to place in each one of your accounts. This code references a single Google Spreadsheet (here is a sample one for you to copy: http://goo.gl/y6hPfy) that it uses to know what scripts it is supposed to run. The spreadsheet has only 3 columns: A description which is just used for logging, the location of the script in Google Drive, and the Object Name in the script. Don't worry about that right now, I will describe it better in the next section. Finally, it loads the script file and executes the main function.

/************************************
 * Generic Script Runner
 * Version 1.0
 * Created By: Russ Savage
 * FreeAdWordsScripts.com
 ***********************************/
function main() {
  //See http://goo.gl/KvINmD for an example spreadsheet.
  var scriptConfigId = 'Your Spreadsheet Id Goes Here';
  var sheet = SpreadsheetApp.openById(scriptConfigId).getActiveSheet();
  var data = sheet.getRange('A:C').getValues();
  for(var i in data) {
    if(i == 0) { continue; }
    var [description, location, classname] = data[i];
    if(!location) { continue; }
    Logger.log('Running "'+description+'" from location: '+location);
    var scriptFile = getFile(location);
    var scriptText = scriptFile.getBlob().getDataAsString();
    eval(scriptText);
    var script = eval('new '+classname+'();');
    script.main();
  }
}
 
//This function gets the file from GDrive
function getFile(loc) {
  var locArray = loc.split('/');
  var folder = getFolder(loc);
  if(folder.getFilesByName(locArray[locArray.length-1]).hasNext()) {
    return folder.getFilesByName(locArray[locArray.length-1]).next();
  } else {
    return null;
  }
}
 
//This function finds the folder for the file and creates folders if needed
function getFolder(folderPath) {
  var folder = DriveApp.getRootFolder();
  if(folderPath) {
    var pathArray = folderPath.split('/');
    for(var i in pathArray) {
      if(i == pathArray.length - 1) { break; }
      var folderName = pathArray[i];
      if(folder.getFoldersByName(folderName).hasNext()) {
        folder = folder.getFoldersByName(folderName).next();
      }
    }
  }
  return folder;
}

Now that we have a generic piece of code that reads the description, location, and object name from a spreadsheet and executes code, we need to make some slight modifications to some of our existing scripts to get it to work.

One of my favorite scripts is the one about Finding Anomalies in Your Account. In order for the script to be run from another script, we need to convert it into an object with a single public function. This same technique should work on almost all of the scripts from FreeAdWordsScripts.com.

First, surround the entire script in a function call and give it whatever name you like.
function Anomalies() {
 // Copy and Paste the code from:
 // http://goo.gl/IT1UcV
};
Next, you need to update the main function to be a public method so that we can call it from our generic script.
this.main = function() {
 // Don't make any changes to the body of the main method
}

A full version of the updated code can be found here: Find Anomalies in Your Account Object Version.

Now you can save this new script somewhere in your GDrive and update the Location and Object Name (Anomalies in this case) in your config spreadsheet.

Now you should be good to go. You can add as many scripts as you like to the config spreadsheet but keep in mind that the 30 minute limit still applies.

Thanks,
Russ

127 comments:

  1. if you are looking for best whatsapp group then visit our site whatsapp group link

    ReplyDelete
  2. thanks for ur valuable information,keep going touch with us

    Scaffolding dealers in chennai

    ReplyDelete
  3. Nice Presentation and its hopefull words..
    if you want a cheap web hostinng in web
    cheap web hosting company chennai

    ReplyDelete
  4. Thanks for sharing this article. For more Online Shopping Offers Whatsapp Groups you can visit
    Whatsapp groups
    Whatsapp groups links
    Whatsapp groups Invite links

    ReplyDelete
  5. professional bridal makeup artist in chennai Style Specializes in beauty bridal makeup and makes assured that individual bride should look like a princess.

    best bridal makeup artist in chennai

    ReplyDelete
  6. Thanks for sharing this article. For more Online oreder Offers,Coupons & promo Codes you can visit
    Uber Eats promo code
    Uber Eats coupons
    Uber Eats offers
    Uber eats today promo code

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Soma pill is very effective as a painkiller that helps us to get effective relief from pain. This cannot cure pain. Yet when it is taken with proper rest, it can offer you effective relief from pain.
    This painkiller can offer you relief from any kind of pain. But Soma 350 mg is best in treating acute pain. Acute pain is a type of short-term pain which is sharp in nature. Buy Soma 350 mg online to get relief from your acute pain.

    https://globalonlinepills.com/product/soma-350-mg/


    Buy Soma 350 mg
    Soma Pill
    Buy Soma 350 mg online



    Buy Soma 350 mg online
    Soma Pill
    Buy Soma 350 mg

    ReplyDelete
  9. WhatsApp Status Video Download :WhatsApp introduced the status feature in 2015, in which we can share images, videos, and gifs as our story for 24 hours. Before this feature, WhatsApp had only text status option in which we can write our bio, but the new status feature is different. The story or status disappears after 24 hours and can’t be archived as still in WhatsApp.

    Boy attitude status video download for whatsApp
    Boy attitude status video download
    Boy attitude status video download

    Most romantic status video download for whatsApp
    Most Romantic status video download
    Most Romantic status video download

    video status download for whatsApp


    we have latest & best collection of video status download for whatsapp

    ReplyDelete
  10. I am very happy to see this post because it is very useful for me because there is so much information in it. I always like to read quality and I'm happy that I got this thing in your post. Thanks for sharing the best article post. visit Pepperfry coupons pepperfry furniture offers pepperfry Sofa

    ReplyDelete
  11. Grow sale india classified ads website Buy&sell find just about anything

    post free classified ads in india

    ReplyDelete
  12. A & P ASSOCIAATES is supplier and trader of plastic packaging box,packaging pallets,plastic containers based in Chennai - Tamil Nadu, India

    vito food oil dealers in chennai

    ReplyDelete
  13. One of the best scaffolding ladder dealers in chennai, variety of designs and models are available here,please visit us
    Scaffolding dealers in chennai

    ReplyDelete
  14. Fourceup Security is a best security service in chennai based upon Factories ,Offices ,Banks & their ATM ,Hotels ,Hospitals ,Schools ,Residential Apartments ,Construction Sites(Conditions Apply) ,Functions ,Tracking Crime systems.

    best security service in chennai
    security agency in chennai

    ReplyDelete
  15. Its a right place to spend a lots of your valuable times with chat items. "yaa karachi is here for you "

    best cafe in chennai

    ReplyDelete
  16. professional bridal makeup artist in chennai Style Specializes in beauty bridal makeup and makes assured that individual bride should look like a princess.

    best bridal makeup artist in chennai

    ReplyDelete
  17. The post is absolutely fantastic! Lots of great information and inspiration both of which we all need! Also like to admire the time and effort you put into your blog.

    web portal development services in chennai

    ReplyDelete
  18. Dr Driving is one of the my favourite game ever and today I am going to share Dr Driving Mod Apk
    https://www.drdrivingmodapk.xyz/

    ReplyDelete
  19. Whatsapp Group Link - 5000+ Updated Whatsapp Groups
    whatsapp group link Click The link And Join Whatsapp New Groups, Dating, Business promositions Groups https://grouplien.com

    ReplyDelete
  20. Thanks for sharing this post. This blog was amazing. I am impressed with your thoughts. I got the best information about this topic here and is very useful for all of us. Please visit Online Shopping Coupons , and I hope you may also like our services.

    ReplyDelete
  21. I am very happy to see this post because it is very useful for me because there is so much information in it. I always like to read quality and I'm happy that I got this thing in your post. Thanks for sharing the best article post. visit Big basket offers Big basket coupons

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete
  23. thanks for sharing this kind of topics.
    best AWS Solutions Architect Training in Bangalore
    https://onlineidealab.com/aws-training-in-bangalore/


    ReplyDelete
  24. thanks for sharing this topics.its really useful for us.
    best AWS Certification course
    https://onlineidealab.com/aws-certification/

    ReplyDelete
  25. Really great article, you guys are doing a great work, keep posting good stuff, If your audience is into Tech do share 30 MiUi 11 Tips and Tricks
    Gizdoc Tech Paradise

    ReplyDelete
  26. Looking for best English to Tamil Translation online, make use of our site to enjoy Tamil typing and directly share on your social media handle. Tamil Romantic Novels

    ReplyDelete
  27. Handling Solutions Products - Here is the link of best Handling Solutions products of Taldeen. Taldeen is one of the best Plastic Manufacturing Company Based in Saudi Arabia-Hail. Visit the below links to know more about products details
    Handling Solutions
    Plastic Pallets

    ReplyDelete
  28. BMIT – BSc Medical Imaging Technology – Here is the details about Best BSc Medical Imaging Technology Colleges In Bangalore. If you are looking to study in Bangalore, the below link will redirect to a page that will show the best BMIT colleges in Bangalore
    BSc Medical Imaging Technology Colleges In Bangalore

    ReplyDelete
  29. BSc Cardiac Care Technology – Here is the details about Best BSc Cardiac Care Technology Colleges In Bangalore. If you are looking to study in Bangalore, the below link will redirect to a page that will show the best BCC colleges in Bangalore
    BSc Cardiac Care Technology Colleges In Bangalore

    ReplyDelete
  30. BSc in Optometry – Here is the details about Best BSc Optometry Colleges In Bangalore. If you are looking to study in Bangalore, the below link will redirect to a page that will show the best OPT colleges in Bangalore. If you are looking to study BSc Optometry in Bangalore, click the below link.
    Optometry Colleges In Bangalore

    ReplyDelete
  31. BBA Aviation – One of the most demanding management course in recent times. Here is the details of Best BBA Aviation colleges in Bangalore. If you are looking too study in Bangalore, visit the below link.
    BBA Aviation Colleges In Bangalore

    ReplyDelete
  32. GrueBleen – One of the best branding and marketing agency in Riyadh- Saudi Arabia. If you need the details, click the below link
    Branding Agency Riyadh
    Marketing Agency Riyadh

    ReplyDelete
  33. Agriculture Solutions – Taldeen is a plastic manufacturing company in Saudi Arabia. They are manufacturing agricultural plastic products like greenhouse cover and hay cover. Visit the below link to know more details
    Agriculture Solutions
    Greenhouse Cover

    ReplyDelete
  34. Medical Imaging Technology – One of the most demanding allied health science course in recent times in India. Check out the details of Best BSc Medical Imaging Technology Colleges Details with the following link.
    BSc Medical Imaging Technology Colleges In Bangalore

    ReplyDelete
  35. BSc Perfusion Technology – If you are looking to study BSc Perfusion Technology in Bangalore, just check out the following link. In that link you can get the details of Best BSc Medical Imaging Technology colleges in Bangalore
    BSc Perfusion Technology Colleges in Bangalore

    ReplyDelete
  36. GrueBleen – One of the best social media marketing agency in Riyadh- Saudi Arabia. Visit here for the all service details of GrueBleen.
    Social Media Marketing Agency

    ReplyDelete
  37. PNJ Sharptech is a leading Social Media Optimization company in India, specializing in handling both organic and paid Social Media Marketing (SMM) campaigns successfully. We have many years of experiencing increasing online social presence on various social media platforms such as Facebook, Twitter, LinkedIn and Pinterest, and many others. Our SMO experts have a rich knowledge of increasing traffic and maintaining the online social reputation for a long period. How our SMO services make you different from others? Our low-cost social media marketing services are very helpful to build your online reputation and increase sales.

    ReplyDelete
  38. Guglu muglu with its Punjabi Song LYRICS by Jasmine Sandlas in songwriting of Ranbir Grewal is a latest track. Lavkesh Vishwakarma is director music Rosleen Sandlas shot the music video for it. Read Guglu muglu Song Full Song Lyrics and also watch the official music video.GUGLU MUGLU Song LYRICS – Jasmine Sandlas

    ReplyDelete
  39. If the area of law that you are going to specialize in is Intellectual Property then marketing classes would be useful to you.
    ExcelR Digital Marketing Courses In Bangalore

    ReplyDelete
  40. This post is really nice and informative. The explanation given is really comprehensive and informative...

    software testing courses for beginners

    ReplyDelete
  41. live draw hk banyak terdapat perbedaan dari situs2 penyedia live hk ini. Sedikit saran apabila anda setiap harinya mengikuti live draw hk kami pastikan selalu menggunakan situs live hk yang kami rekomendasikan saja. Termasuk juga untuk live draw sgp ataupun live sgp alternatif ini.

    ReplyDelete
  42. Sarkari Result Apply .com is a No.1 websites for the job finder in government sector in India.
    Click here

    ReplyDelete

  43. You write this post very carefully I think, which is easily understandable to me. Not only this, but another post is also good. As a newbie, this info is really helpful for me. Thanks to you.
    Tally ERP 9 Training
    tally classes
    Tally Training institute in Chennai
    Tally course in Chennai

    ReplyDelete
  44. Poker online situs terbaik yang kini dapat dimainkan seperti Bandar Poker yang menyediakan beberapa situs lainnya seperti http://62.171.128.49/hondaqq/ , kemudian http://62.171.128.49/gesitqq/, http://62.171.128.49/gelangqq/, dan http://62.171.128.49/seniqq. yang paling akhir yaitu http://62.171.128.49/pokerwalet/. Jangan lupa mendaftar di panenqq

    ReplyDelete
  45. Thanks for the interesting blog that you have implemented here. Very helpful and innovative. Waiting for your next upcoming article.
    Digital Marketing Course In Kolkata

    ReplyDelete

  46. This post is really nice and informative. The explanation given is really comprehensive and informative. I also want to say about the complete digital marketing course

    ReplyDelete
  47. What is a network engineer? This is someone who you may also hear referred to as a computer network architect. Network engineer requirements include essential skills in the design, planning, implementation and monitoring a computer network that supports wireless network services, video, data, and voice. This is a high-level profession. There are a lot of different types of networks that someone in this role can work with. Some examples include VoIP, which is Voice Over Internet Protocol Network, DAN - Desk Area Network, PEN - Personal Area Network, WLAN, which is Wireless Local Area Network, and LAN, which is Local Area Network.

    ReplyDelete
  48. TrendMiner Wow, incredible blog layout! How long have you been running a blog for? you make running a blog glance easy. The whole glance of your web site is fantastic, as neatly as the content!

    ReplyDelete
  49. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. digital marketing course Bangalore

    ReplyDelete
  50. Thanks for the blog post. check the similar The first professional networking platform for commissions
    Find - Visit profiles offering commissions
    Connect - Contact with best commission providers near you
    Commission - Work or refer the business and get agreed commission
    Sales commission

    ReplyDelete
  51. I work as a marketing specialist and staff author at Externetworks which is a pioneer in Managed Technology Services with over 17+ years of experience in providing end-to-end solutions featuring design, deployment and 24*7 support to top IT companies. We offer world-class managed services for businesses to stay agile & profitable. Our services include 24/7 Network Monitoring, Uptime maintenance, NOC Support, IT Helpdesk services.
    To know more click here: it services and support

    ReplyDelete
  52. I have to search sites with relevant information on given topic ExcelR Digital Marketing Class In Pune and provide them to teacher our opinion and the article.

    ReplyDelete
  53. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!. bangalore digital marketing course

    ReplyDelete

  54. Using SEO for your website is the perfect way to boost your ranking in the search engines top lists. It is important to have a good DA(Domain Authority) and very low Spam Score, these two are achievable by doing SEO(Search Engine Optimization) following the google norms and instructions. So, therefore it's must to have the support of a good reputedSEO Agency for your Digital marketing purpose.We are a SEO Agency in chennai which provides SEO Serivces. We follow only latest methods and strategies.

    ReplyDelete
  55. newbug.co provides you the movie reviews, latest news, trending news or ... Hindi dubbed movies all movies are available on 7starHD.com

    ReplyDelete
  56. Thanks for sharing such amazing article with us.
    Checkout here more Girls Whatsapp Group Links | Tamil Whatsapp Group Links

    ReplyDelete
  57. The punjabi song based on friendship mere yaar modh do is sung and lyrics penned by Guru Randhawa & Millind Gaba while music composed by Millind Gaba.

    ReplyDelete
  58. Greetings! Very useful advice within this article! reviews It's the little changes that make the most important changes. Many thanks for sharing!

    ReplyDelete
  59. I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.satta king

    ReplyDelete
  60. Thanks for sharing information. Choosing computer accessories from leading IT store offer great discount and value for your money Computer Store Australia | All in One Pc Australia

    ReplyDelete
  61. There's definately a lot to know about this topic. I love all of the points you have info made.

    ReplyDelete
  62. With the help of creative designing team TSS advertising company provides different branding and marketing strategies in advertising industry...
    https://www.tss-adv.com/branding-and-marketing

    ReplyDelete
  63. Thanks for sharing this article. Save you huge money & time. Download the Tracedeals Online Deals & Coupons&Sign In to get daily alerts from your favorite stores
    Online Shopping App
    Coupons and Offers App for Shopping Online
    Online Shopping Deals & Coupons App
    Online Shopping Offers & Coupons App
    Offers,Deals & Coupons App

    ReplyDelete

  64. TeaTv Apk Is Another One Of The Best Online Streaming Application For Smartphone Users. This Application Is Available For Android & IOS Users. Also, You Can Connect This Application Easily With Amazon Firestick, Android Smart TVs, Start Settop Box, Etc. There are more apk to online streaming is Mediabox apk for smartphone users ( Android and ios ) and
    Best Wishes Quotes 
    Watch Free online Movies 
    onhax 
    onhax android 
    Hulu Apk 

    ReplyDelete