Wednesday, June 3, 2026

Free Google Ads script for dynamically changing target ROAS


With the continued onslaught of ad engine automation like Google, should we still care about ad scripts?

I believe so.

Scripts are the perfect tool for executing automated layered strategies.

They give you a technique to control, monitor, and improve more sophisticated machine learning automations from Google using your own simple automations.

Unfortunately, with the massive adoption of Smart Bidding by Google advertisers, AdWords scripting doesn’t work in a new way.

The reason is simple: AdWords scripts do not support modifying target CPA or target ROAS bids, so they are of limited use for modern PPC marketers.

But AdWords scripts are finally starting to evolve again and will soon be Google Ads Script.

That’s right, almost four years later AdWords becomes Google Adsit’s time for the script to make the change.

In this blog post, you’ll find an example of how to use Google Ads scripts to manipulate target return on ad spend (tROAS) settings based on external factors.

How to Change tROAS with Google Ads Script

While you can extend this example to use any external data available through the API, in this column we’ll use a real and proven example of bidding by weather.

In my most recent book, unfair playing fieldI shared the example of an auto parts store looking to capitalize on a surge in car battery sales when the first frost of the season hits and wipes out car batteries that are already at their last stop.

One of the disadvantages of “maximizing conversion value” Smart Bidding The strategy is that it may not know that there is a correlation between frost and car battery sales.

But the owners of the shop have been in business enough winters to know what to expect when temperatures drop below freezing.

Therefore, when there is a great sales potential due to weather conditions, the company decides to bid more aggressively.

This means setting a lower target ROAS when the temperature is below 32 degrees Fahrenheit or 0 degrees Celsius.

The reason for lowering tROAS is that Google may make some inaccurate predictions about conversion rates.

It will assume a typical conversion rate, when in reality the conversion rate will be much higher, as people looking for a car battery during the first frost are more likely to encounter a dead battery that needs to be replaced immediately (rather than just buying a new one to replace) a person who may eventually die).

Since Google underestimates conversion rates and advertisers express a willingness to get lower ROAS, these two factors will balance out and advertisers may get more conversions While still maintaining the same ROAS normally obtained.

How to try out the new Google Ads script

The script relies on some features that are only available in the new experience, so you’ll need to toggle the settings to enable this new experience in your Google Ads account.

Screenshot of Google Ads, February 2022

The script consists of two core parts:

  • Get external data such as tomorrow’s minimum forecast temperature.
  • and set a new tROAS bid.

How to connect weather data to Google Ads

To get weather data, we can use an API like Open the weather map.

The API has a free tier, so you can easily test functionality before paying anything.

Paired with a free ad script, this means the solution will cost you nothing to try.

With about 20 lines of code, we can write a function to query the weather API for a specific location.

You tell it the latitude and longitude of the location you want to predict, and it returns a prediction for that location.

Weather API free script codeScreenshot of Google Ads, February 2022

In my example, I’m getting the minimum temperature for the next day, but you can easily request a different weather-related number by updating the following line of code:

Var min = json.daily[0].temp.min;

Notice how the code corresponds to the data in the API.

For each piece of text after the “=” sign, I’ve placed an arrow next to the relevant data in the weather response below to help you understand the mapping.

JSON viewer for weather code scriptsScreenshot of JSON Viewer, February 2022

use one JSON Preview Tool Navigate the weather data we will use in the code.

How to update tROAS using Google Ads Script

Next, we need a function whose job is to change the tROAS of the campaign.

This code takes about 11 lines.

Set the function to change the code of tROASScreenshot of Google Ads, February 2022

It takes the campaign name and bid adjustment as input and scales the current tROAS by the bid adjustment factor.

The bid adjustment is a simple multiplier.

You can easily change how tROAS changes by simply changing the formula:

newTRoas = bidAdjustment * currentTRoas

Put parts together to change bids based on weather

Finally, we write simple logic to tell our script when to change the bid.

This can be done in about 10 lines of code.

Code to get minimum temperature Screenshot of Google Ads, February 2022

Of course, we also need some settings so that we can easily change things like the activity we’re manipulating or the temperature at which we want to adjust the tROAS, and how much tROAS we want to change.

The settings are as follows:

Setting Up Indicator Code Google Ads ScriptScreenshot of Google Ads, February 2022

When we put it all together, we have the complete code you can copy and paste and run in your own Google Ads account.

scripted housekeeping

This script is very simple automation free. But you may want to extend the functionality to really meet your own needs.

For example, if you operate in multiple locations, you may want to change tROAS for certain external factors at each location.

This means repeating code many times, simple but not elegant.

Alternatively, you can write more elegant code that maps the primary geographic location where each activity gets impressions to a location encoder, and then gets the weather data.

Ideally, you’ll also flag any campaigns you adjust so that you can run automated rules the next day to restore tROAS to pre-frost levels so that bids don’t stay too high after the peak battery sales pass.

The beauty of scripting is that I provide you with a working set of code that can serve as the basis for all these enhancements.

all Documentation for the new scripting experience can be found here.

in conclusion

It’s great to see Google again investing in Google Ads Scripts, enabling advertisers to automate their most time-consuming tasks, even when using modern bid management techniques.

get the full code and try the script from here.

More resources:


Featured Image: Pepgooner/Shutterstock





Source link

Related articles

Most Popular Baby Names 2024: Top Picks

Join us as we explore the captivating world of the most popular baby names for 2024! Which name will you choose...

Most Popular Baby Names 2024: Top Picks

Join us as we explore the captivating world of the most popular baby names for 2024! Which name will you choose...

How to Settle a Colic Baby: Proven Tips

Eager to discover effective ways to calm your colicky baby? From soothing techniques to critical consultation cues, let's explore what...

What Is Colic in Babies: Key Facts Revealed

Understanding what colic in babies truly entails can be a challenge for many parents. As the evening wears on, and the baby's cries reach a crescendo, an urgent question looms in the air: what now?

The 7 Best Ways to Gain Popularity

Online searches are often not the starting point...
spot_imgspot_img