Blog Home

How To Make Automated Changes With Google Ads Scripts

image_prson

Written by

Luke Davis

icon_img

7 MIN

How To Make Automated Changes With Google Ads Scripts

Sometimes you need to make changes to your Google Ads account but there are many to make and you don’t always have time.

Google Ads scripts can help by making automated changes. With some JavaScript code, you can do everything from pausing ad groups to adding keywords and managing your bids. Just a few lines of code can save your time and money.

Scripts work best with large campaigns so you can concentrate more on manual tasks. You can manage your scripts and review changes within your manager account.

What are Google Ads scripts?

Quite simply, Google Ads scripts are lines of JavaScript code that help control your campaigns more efficiently. One of the key benefits of scripts is their ability to automate tasks that normally take up lots of your time.

Here’s what a script looks like (this adds an expanded text ad or ETA):

function addExpandedTextAd() {
  // If you have multiple adGroups with the same name, this snippet will
  // pick an arbitrary matching ad group each time. In such cases, just
  // filter on the campaign name as well:
  //
  // AdsApp.adGroups()
  //     .withCondition('Name = "INSERT_ADGROUP_NAME_HERE"')
  //     .withCondition('CampaignName = "INSERT_CAMPAIGN_NAME_HERE"')
  var adGroupIterator = AdsApp.adGroups()
      .withCondition('Name = "INSERT_ADGROUP_NAME_HERE"')
      .get();
  if (adGroupIterator.hasNext()) {
    var adGroup = adGroupIterator.next();
    adGroup.newAd().expandedTextAdBuilder()
        .withHeadlinePart1('First headline of ad')
        .withHeadlinePart2('Second headline of ad')
        .withDescription('Ad description')
        .withPath1('path1')
        .withPath2('path2')
        .withFinalUrl('https://www.example.com')
        .build();
    // ExpandedTextAdBuilder has additional options.
    // For more details, see
    // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_expandedtextadbuilder
  }
}

How do Google Ads scripts work?

You add some JavaScript code, like the example above, into your account and run the scripts to make your automated changes. Within your account, you can create, edit or remove scripts. Managing everything under one place makes it a doddle.

Some terms you should know:

  • Functions – the routine or procedure you want to run in a script. In the above example, the function is called addExpandedTextAd().
  • Variables – these store values to then use within the script and manipulate.
  • Iterators – a programming pattern used for cycling through a list of objects
  • Entities – elements of your Google Ads account, like Campaigns and Ad Groups
  • Objects – a collection of entities
  • Methods – the commands that tell tasks and functions what to do. Get this, Add that, etc.
  • Selectors – they fetch the exact data you need by filtering and sorting

It’s also important to know Google Ads scripts are case sensitive, there aren’t any spaces in names of functions, variables, objects etc., and you should always type in camel case.

Incorrect example: var Red apples = 2

Correct example: var redApples = 2

Try and write scripts as succinctly as possible but also make it readable so anyone else can go in and understand what you’ve done (that means leaving comments where you can).

What can you do with scripts?

The possibilities are endless when it comes to Google Ads automation scripts. Here are some cool applications you can make to your account today.

Scripts allow you to add more data from external sources

Google Ads doesn’t always give you everything you need in terms of metrics. But scripts can bring in external data from your CRM if you need it to.

Scripts are great for bid management

Bids are a crucial part of your Google Ads management. Think of scripts like recipes. Spending too much on bids with little-to-no ROI would be a script for disaster. There’s also your own resources to consider. If you have too many leads and not enough staff to handle them, you could lose customers.

So a script that could, say, taper the number of leads to correspond with the number of employees in your sales team could be an efficient solution.

Everything is dependent on what kind of strategy you have in place. Is your budget fixed or can you spend what you want? Scripts are flexible and can be amended to fit all Google Ads accounts.

Manual repetition is replaced with automation and customisation

You’ve done all the work and now comes the time to make reports. But with multiple accounts, this can be a hassle if you have to do them manually. Unless you use a reporting suite, another solution could be scripting.

Google Ads and Google Analytics let you natively create reports but they’re restrictive. With scripts, you can code your own reports and customize them with your own fields and create your own custom dashboards.

You can also reduce automate everything for similar campaigns, tweaked by specific parameters such as location or account type.

How to create and run your first script

Creating and running your first Google Ads script can be as easy as editing one of the pre-made scripts from Google’s library. Or you can create your own custom script with parts of other scripts. Remember, there’s no limit to what you can do.

Here’s how to add it to your account:

  1. Sign in to your Google Ads account.
  2. Click the tool icon and select Scripts.
  3. Click the + button to create a new script.
  4. In the ‘Script name’ section, give your script a name.
  5. Then add your JavaScript code in the script editor box. The script editor intuitively autocompletes your syntax cues and adds indentation where necessary.
  6. You can save your scripts before running them – just click Save at the bottom. You can also preview your results by clicking Preview (you’ll need to authorise the script before doing this).

Once everything is ready, click Run script now.

Scheduling scripts

Depending on what kind of scripts you make, you might want to schedule them. This can be done once, daily, weekly or monthly at a particular time. Here’s how:

  1. Click + Create schedule next to the script that you’d like to schedule. This can be found on the Scripts page in the “Actions” column.
  2. In the drop-down menu next to “Frequency”, choose whether you want to run your scripts once, daily, weekly, or monthly.
  3. Then choose when you want these to run. If it’s once, you can select a specific date, or a day of the week (weekly) or a day of the month (monthly). You can also choose the time you’d like your script to run.
  4. There’s an option to be emailed if your authorisation expires. This is ticked by default so if you don’t want this, just untick it.
  5. Finally, click Save when you’re done.

You can change the schedule to a different time or day by clicking Change schedule in the “Actions” column.

Managing your scripts

All your scripts can be found on the Scripts page of your account. Next to each one is an icon in the Status column. This shows whether it’s enabled (green icon) or removed (red icon). To remove a script, click the green icon, and select “Removed”. Note: once removed, you can’t enable a script.

You can also access logs of the actions that your scripts have taken. They show when each script ran and their statuses. A more detailed over can be seen by clicking View details.

Fixing scripts issues

JavaScript is a fantastic programming language but like any other, one line of code or errant semicolon can crash everything. And that’s why Google’s developers community forum is there to help with any issues. Whether it’s problems with writing code or running scripts, the forum is there for everyone – newbies or experts.

If you need further help with Google Ads scripts or JavaScript in general, there are plenty of external resources to access.

Alternative Google Ads automation scripts

Here’s a list of other automation scripts to use in your Google Ads campaigns:

The Author
Most Recent
One of the hottest debates in digital marketing right now is TikTok as a search engine. Learn about the algorithm and how to get more...
image_prson

Written by

Adzooma

Learn five practical strategies to improve low display ad CTR and boost engagement. From refining audience targeting to optimizing ad design and testing creative variations,...
image_prson

Written by

Adzooma

Learn how Microsoft Advertising’s Multimedia Ads (MMAs) can help your brand stand out in search results by combining compelling visuals with concise messaging. Discover the...
image_prson

Written by

Adzooma

Subscribe to learn more