Free Google Ads script to dynamically change target ROAS

0

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

I believe him.

Scripts are the perfect tool for executing an automation overlay strategy.

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

Unfortunately, as Google advertisers adopted smart bidding in greater numbers, AdWords scripts became less able to work in the new way of doing things.

The reason is simple: AdWords scripts do not support changing Target CPA or Target ROAS bids, so they are limited in their usefulness for the modern PPC marketer.

But AdWords Scripts have finally started to evolve again and will soon be replaced by Google Ads Scripts.

It’s true, almost four years later AdWords has become Google Adsit’s time for scripts to make the change as well.

In this article, you’ll find an example of using a Google Ads script to manipulate your target return on ad spend (tROAS) based on external factors.

How to use a Google Ads script to change tROAS

While you can extend this example to use any external data available through an API, we’ll be using the tried-and-true Weather Bidding example for the purposes of this column.

In my latest book, Uneven the playing fieldI shared the example of an auto parts store that wants to take full advantage of a surge in car battery sales when the first freeze of the season hits and wipes out car batteries that were already on their final stage.

One of the flaws of the “maximize conversion value” smart bidding strategy is that it probably doesn’t know there is a correlation between gel and car battery sales.

But the store owner has been in business enough winters to know what to expect when the temperature dips below freezing.

The company therefore decides to bid more aggressively when there is great potential for additional sales due to weather conditions.

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

The reason for the drop in tROAS is that Google will likely make inaccurate predictions about conversion rates.

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

Since Google is underestimating the conversion rate and the advertiser is indicating their desire for a lower ROAS, these two factors will balance each other out and the advertiser will likely get more conversions while maintaining the same ROAS they usually get. .

How to try the new Google Ads scripts

The script relies on some features that are only available in the new experience. You will therefore need to activate the setting that activates this new experience in your Google Ads account.

Screenshot of Google Ads, February 2022

The script consists of two main parts:

  • Retrieval of external data such as the minimum temperature expected for tomorrow.
  • And set a new tROAS auction.

How to connect weather data to Google Ads

To fetch weather data, we can use an API like the one in Open Weather Maps.

There is a free tier of the API so you can easily test the functionality before committing to any costs.

Together with a free advertising script, this means that this solution will not cost you anything to try.

With about 20 lines of code, we can write a function that queries the Weather API for a particular location.

You tell it the latitude and longitude of the location you want a forecast for, and then it returns the forecast for that location.

Free weather API script codeScreenshot of Google Ads, February 2022

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

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

Note how this code matches the API data.

For each part of the text after the “=” sign, I have placed an arrow next to the associated data in the weather response below to help you understand the mapping.

JSON viewer for weather code scriptJSON Viewer screenshot, February 2022

Use a JSON Preview Tool to navigate through the weather data that we will use in our code.

How to update tROAS with Google Ads scripts

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

This code takes about 11 lines.

code to define the function to modify the tROASScreenshot of Google Ads, February 2022

It takes a campaign name and a bid adjustment as inputs and it scales the current tROAS by the bid adjustment factor.

Bid adjustments are a simple multiplier.

It is trivial to change the way the tROAS is modified by simply changing the formula:

newTRoas = bidAdjustment * currentTRoas

Assemble the pieces to change the bid depending on the weather

Finally, we write the simple logic that tells our script when to change the bids.

This can be done in about 10 lines of code.

code to get the lowest temperature Screenshot of Google Ads, February 2022

Of course, we also need some parameters so that we can easily modify things like the campaign we are handling or the temperature at which we want to adjust the tROAS, and how much we want to modify the tROAS.

The settings look like this:

Google Ads script statistics code definitionScreenshot of Google Ads, February 2022

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

Cleaning scripts

This script performs a very simple automation for free. But chances are you want to expand the functionality to really meet your own needs.

For example, if you operate in many locations, you might want to modify the tROAS for an external factor in each of those locations.

This means repeating the code several times, which is simple but not elegant.

Or, you can write more elegant code that maps the primary geolocation where each campaign gets impressions to a location encoder and then fetches weather data.

Ideally, you’ll also tag any campaigns you adjust so you can run an automated rule the next day to restore tROAS to pre-freeze levels so bids don’t stay too high after battery sales peak.

The beauty of scripting is that I’ve given you a set of working code that can be the basis for all of these improvements.

All documentation for the new scripting experience can be found here.

Conclusion

It’s exciting to see Google investing again in Google Ads scripts, allowing advertisers to automate even their most time-consuming tasks using modern bid management techniques.

Take the full code and try the scenario from here.

More resources:


Featured Image: Pepgooner/Shutterstock

Share.

About Author

Comments are closed.