Turn a spreadsheet into AdWords ads

Enhanced Script: Create Ads From a Spreadsheet

This script has been replaced by the Campaign Automator, a stand-alone solution from Optmyzr that is ideal for creating and maintaining a Google Ads account from your business data. Contact our team for a free trial.


This AdWords Script automatically creates ad groups, ad texts, keywords and labels based on your template and a spreadsheet of your data. It can be used to turn a product database into an AdWords account or it can be used as an alternative to the AdWords interface or the AdWords Editor for creating new ads. Because the code can be easily modified, it is also more flexible than most solutions that involve the AdWords API.

Turn a spreadsheet into AdWords ads
Turn any Google Spreadsheet into AdWords ads using the template you define in our AdWords Script.

Example Use Cases

This AdWords automation is useful for a wide range of use cases:

  • Advertisers who already have a spreadsheet of all their services and products can use this to build out an account with great structure that will benefit your quality score.
  • Agencies who work with a lot of clients in the same vertical and who have a well defined best practice for building out new accounts can use this to speed up new account creation.
  • Advertisers whose inventory changes frequently can use this to tie their ad creation directly to their backend.
  • Agencies who create Google Merchant Feeds can use this to add a value-add service where they use the feed to create AdWords ads for their clients.

Settings and Customizations

  • SOURCEDATA tells the script the location of the Google Spreadsheet that contains your data.
  • NAMEOFDATASHEET tells the script the name of the sheet in the spreadsheet that contains the data. A spreadsheet can contain multiple sheets and this lets the script know which one to use.
  • EMAILADDRESS tells the script the email addresses that should get a notification when it finishes creating ads. To send to multiple recipients, separate the email addresses with a comma. Do NOT include the name of the person... only include their email address.
  • ACCOUNTNAME is used by the script to create the subject line of the email it sends. When you're using this script on multiple accounts, it makes it easier to know which account each email notification is about.

Under The Hood

The script will automatically add a new column called "Added to Accounts" to your Google Spreadsheet. When it creates an ad using this row of the spreadsheet, it adds the account ID in this column. The next time the script runs, it will skip this row. This is useful to prevent adding duplicate ad texts and to make the script faster, for example by only making ads for rows you added to the sheet since you last ran it.

 How To Use The Script To Generate Ads Automatically


Get This Script

This script is deprecated and has been replaced by the Campaign Automator, a stand-alone solution from Optmyzr that is ideal for creating and maintaining a Google Ads account from your business data. Contact our team for a free trial.

9 thoughts on “Enhanced Script: Create Ads From a Spreadsheet

  1. This is an extremely useful script. I'm very excited about it.

    It looks like the script will enable ad groups if an ad group already exists. For example, if the ad group "Chocolates" already exists but is currently paused, the script will enable the ad group if it finds "Chocolates" in the spreadsheet.

    Does it pause enabled ad groups that no longer appear in the spreadsheet? Suppose the name "Chocolates" ceases to appear in the spreadsheet. Does the script run through the enabled ad groups, looking for each one in the corresponding columns in the spreadsheet? And if the ad group is not found, pause it?

    How about ads? How does it handle changes to the values used to create ads within a single ad group? For example, suppose the values retrieved from the spreadsheet for a set of ads within an ad group are name=Chocolates, price=9.99. What happens if tomorrow the values are name=Chocolates, price=14.95? Does it "edit" the ads, i.e. replace the values of the original ad? Does it delete the existing ads and create new ads? Does it do nothing to the existing ads and simply create additional ads? Or does it do nothing at all if the ad group already exists?

    1. Hi Dave,

      Glad to hear you find this script useful!

      It does NOT pause any ad groups it no longer sees in the sheet. Some users may use this script to add ad groups to pre-existing campaigns and in that case I did not want to pause their old ad groups. The script keeps track of all the ad groups it creates or edits so it could compare that to the list of ad groups in the campaign and pause any that are not on that list.

      The script currently does NOT create ads if the ad group already exists before the script runs. This is handled by line 315: "if(adGroupExisted == 1) break;". If you delete this line, then the script will create NEW ads every time it runs. If you wanted it to replace ads, you'd have to add a few lines of code to delete the ads in the ad group.

      For handling frequently changing prices in ads, you may want to use ad params in the ad text instead, e.g. {param1:$6.99} and then update the value of param1 with the API. If this is what you're looking for, let us know and we can explain our advanced API tools.

      Hope that helps!

  2. I am receiving a run time error with the following error:

    TypeError: Cannot call method "getDataRange" of null. (line 46) Please advise on how to fix this.

  3. Thank you very much for this script, it is working very well however I have one issue, the name of my product is a part number that contains a hyphen, when the script is creating the keywords it is removing this hyphen which is important to the keyword, how do I fix this?

  4. Hi Frederick! Can I run the script without making changes to my Campaigns? I would like to have the ads, keywords and ad groups e-mailed to me so I can review and upload to Editor before going live.

    Can I do that?

  5. I have a question unrelated to this post. I have an ad group with 10 ads, for users coming from an specif audience i would like to show only 3 of these 10 ads. Is it possible to do it with a script? It's a strategy based on showing specif ads according to the last page visited on my website.

    1. Hi Helena,

      At the moment, Optmyzr doesn't have a way to show specific ads from an ad group for users coming from specific audiences or based on the last website they've visited. I'll share your request with our Engineering team for them to evaluate it. They release updates every month, so we'll get back to you as soon as we get an update from them.

      If you want to show relevant ads to searches of people you're trying to reach, then at the moment, the only way you can do it is to bundle related ads together with related keywords into an ad group.


Comments are closed.