An Introduction to Google Ads Scripts

Written by Wes Parker

Posted on: August 19, 2020

I genuinely believe that Google Ads scripts are the most powerful tool in a PPC manager’s arsenal.

With a few short lines of JavaScript code, you can automate almost any task within Google Ads.

Moreover, you can connect Google Ads to external data sources, allowing you to do all sorts of cool stuff, from bidding based on the number of rooms available in your hotel to turning your ads on or off if it’s snowing.

And lots of mind-numbingly boring stuff, too, such as creating reports and removing poorly performing ads and keywords.

The best thing is that you don’t even need to code. There are hundreds of prebuilt scripts that you can simply copy and paste into your account.

In this article, we’re going to look at why Google Ads scripts are so useful and how you can set them up, as well as where you can find hundreds of pre-made ones that you can copy and paste into your account to use straight away.

What you can do with Google Ads scripts

  • Automate tedious tasks that don’t require any higher cognition. Lots of tasks that a PPC manager does on a day-to-day basis are mundane and tedious. At DemandMore, we’ve managed to automate around 80% of these tasks, allowing account managers to focus on more interesting stuff, such as strategy, and we suggest that you do the same.
  • Get more done with fewer human errors. I’ve yet to meet an account manager who works on a Google Ads account 24 hours a day and never makes a mistake. Google Ads scripts can run each hour of the day, 24 times per day, making millions of changes with no errors. Pretty good, right?
  • Spend more time strategising and less time manually reporting. Most PPC account managers spend so much time implementing and putting out fires that they hardly spend any time strategising on their accounts. By automating all of the reporting and 80% of management tasks, it allows them to spend time analysing reports in detail and putting together a strategy to continually improve performance.
  • Make adverts dynamically at scale. When you’ve got 100,000 products and you need to write ads for each one, you’re in for a long afternoon. Not with scripts! This is a great example of a task that you could quickly automate in a few minutes using a template that is then populated with product data, such as the name, price and stock level.
  • Overcome limitations within the Google Ads platform. For example, using manual scheduling, you can’t change bids more than six times per day, which, when conversion rates fluctuate hour to hour, isn’t so great. However, with the use of a Google Ads script, you can set up a schedule to run 24 times per day, making you more agile than 99% of your competitors, who are limited by Google’s platform.
  • Incorporate external data. As I’ve touched on before, scripts allow you to incorporate external data sources. You can use this for reporting – for example, by connecting to Google Sheets to output a report. It can also be used for notifications, so that Google sends you an email or a text message when certain things happen, or for bidding, either based on your own in-house data, such as availability of rooms in a hotel, or products in stock. You could also use it to bid based on forex rates, crime rates or weather data, as we’ve done for our clients.

How to set up Google Ads scripts

So, you’re confronted with a scary-looking block of code, which looks like you’d need a PhD in computer science to understand it.

But fear not – Google Ads scripts are fairly easy to set up, even if you’ve never written a line of code in your life.

Step 1. Navigate to the Google Ads script dashboard

First head to the Google Ads script dashboard by clicking on the tools icon, then from the main menu under the Bulk Actions header, select “Scripts”.

Step 2. Click the blue + icon in the top left-hand corner

Click the blue + icon in the top left to add a new script.

Step 3. Paste the script into the account

Copy and paste the script that you want to use into the account and you should end up with something that looks like this. For most scripts, you’re now ready to go. Not too difficult, right?

Step 4. Configure the script to your requirements

Most scripts have some form of configuration within them that you can change.

Carefully read the documentation and make the changes within the controls section of the script to customise the functionality. This is usually located at the top of the script.

A couple of the most common configurable steps are adding a URL for a Google Sheet to create a report, and adding campaigns or ad groups to be included or excluded.

Step 5. Authorise the script, preview it and run it!

In most cases, there is a yellow bar across the top of the screen, asking you to authorise the script to run. Simply click the “Authorise” button to give the script permission to run.

Once you’ve done this, hit the “Preview” button to see a log statement that shows you what changes the script would make if it were run.

If it all looks OK at this point, hit the “Run” button and your script runs for the first time.

Step 6. Set the frequency at which you want the script to run

You’ll want to run most scripts on a schedule, so they automatically run on an hourly, daily or monthly basis.

Some scripts, such as the 24-hour bidding script, for example, need to run on an hourly basis for them to work as desired.

Quality Score trackers, such as this one, usually have to be scheduled to run on a daily basis, so they plot quality score fluctuations to a graph for each day, for example.

It’s important that you read the documentation here to see if there are any specific scheduling requirements for the script to run as intended.

If not, you can simply run the script on an ad hoc basis when you need the functionality.

The anatomy of a basic Google Ads script

Source: Search Engine Land

There are several elements that make up a basic GoogleAds script:

  • Function: A function is a block of code contained between two curly brackets, which can be run by being called. You call the function by writing out its name.
  • Variable: This stores information that can be accessed later on.
  • Objects: An object is a collection of entities. In this case, the object is
  • Entities: The AdWordsApp object is made up of several entities, such as campaigns, ad groups and keywords. Here, on the second line, the entities are keywords.
  • Selectors: Selectors allow you to narrow down the choice of entities that you have selected. Here, the selector finds only keywords that are enabled, then sorts them in descending order by impression based on yesterday’s data. It then limits the list to 10 keywords.
  • Methods: Methods are tasks – for example, “Get”, “Set” and “Add”. In this case, the method is “Get”.
  • Iterator: Iterators tell the script to keep going in a loop. Here, for example, while there is still another keyword in the list, the script will keep running.
  • Logger output: Logger output allows you to write to the preview panel, which is great for debugging. However, it slows your script down, so consider removing this once you’re happy that the functionality looks correct.


Prebuilt scripts

There are lots of great resources for finding prebuilt Google Ads scripts that you can just copy and paste into your Google Ads to start automating boring tasks:

Building your own scripts

If you’re looking to build your own scripts, we suggest checking out:

  • Codecademy – it has a great introductory course on JavaScript code.
  • Google For Developers – Google documentation is a great place to find code snippets and examples of how you should develop your Google Ads scripts, as well as being a comprehensive reference document. It is also worth checking out the site because they often run introductory courses on Google Ads scripts that you can attend in London.
  • SMX East presentation on Google Ads scripts, by Steve Hammer and Russell Savage.
  • Adwords Scripts for Every Level Part 1 – the first in a four-part series by Search Engine Land that teaches you how to read Google Ads scripts.
  • Adwords Scripts for Every Level Part 2 – the second edition, with intermediate tips on troubleshooting script errors.
  • Adwords Scripts for Every Level Part 3 – the third part on building your own Google Ads scripts, with advanced tips on unleashing the power of scripts.
  • Adwords Scripts for Every Level Part 4 – the fourth and final edition of the series, with a free case study on how to use scripts.