Connect with us


Free Google Ads Script To Dynamically Change Target ROAS



Free Google Ads Script To Dynamically Change Target ROAS

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

I believe so.

Scripts are the perfect tool to execute an automation layering strategy.

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

Unfortunately, as Google advertisers have adopted smart bidding in larger numbers, AdWords scripts have become less capable of working in the new way of doing things.

The reason is simple: AdWords Scripts don’t support modifying target CPA or target ROAS bids, so they’re limited in how useful they can be for the modern PPC marketer.

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


That’s right, almost four years after AdWords became Google Ads, it’s time for scripts to make the change, too.

In this post, you’ll find an example of how you can use a Google Ads script to manipulate your target return on ad spend (tROAS) setting 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 that is available through an API, we’ll use the true-and-tried example of bidding by weather for the purpose of this column.

In my recent book, Unlevel the Playing Field, I shared an example of an automotive parts store that wants to take full advantage of a spike in car battery sales when the season’s first frost hits and wipes out car batteries that were already on their last leg.

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

See also  Why Did Your Google Business Profile Get Suspended?

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

So the company decides to bid more aggressively when there is a large potential for more sales due to weather conditions.

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


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

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

As Google underestimates the conversion rate, and the advertiser indicates a willingness to get a lower ROAS, these two factors will balance out and the advertiser is likely to get more conversions while still maintaining the same ROAS they usually get.

How To Try The New Google Ads Scripts

The script relies on some functionality that is only available in the new experience so you will need to toggle the setting that enables this new experience in your Google Ads account.

Screenshot from Google Ads, February 2022

The script consists of two core parts:

  • Fetching external data like the min forecast temperature for tomorrow.
  • And setting a new tROAS bid.

How To Connect Weather Data To Google Ads

To fetch weather data, we can use an API like that from Open Weather Maps.

See also  More Search Console Insights Added to Google Data Studio

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

Paired with a free Ads Script, this means this solution won’t cost you anything to try.

With just 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 for which you want a forecast and then it returns the forecast for that location.

Weather API free script codeScreenshot from Google Ads, February 2022

In my example, I am fetching the lowest temperature for the next day but you could easily request a different weather-related number by updating the following line of code:

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

Note how that code corresponds to the data from the API.

For every 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 scriptScreenshot from JSON Viewer, February 2022

Use a JSON preview tool to navigate the weather data we’ll use in our code.

How To Update tROAS With Google Ads Scripts

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

That code takes about 11 lines.

code to set function to change the tROASScreenshot from 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.

The bid adjustments is a simple multiplier.

It’s trivial to change how the tROAS is changed by simply changing the formula:

newTRoas = bidAdjustment * currentTRoas

Putting The Parts Together To Change Bid By Weather

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

See also  Sanding Google Floors

This can be done in around 10 lines of code.

code to get lowest temperature Screenshot from Google Ads, February 2022

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

The settings look like this:

setting metrics code Google Ads scriptScreenshot from 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.

Scripts Housekeeping

This script does very simple automation for free. But chances are you will want to extend the functionality to really meet your own needs.

For example, if you operate in many locations, you may want to change the tROAS for some external factor in each of those locations.

That means repeating the code many times, which is simple but not elegant.

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

Ideally, you’ll also label any campaigns you adjust so that you can run an automated rule the next day to restore the tROAS to pre-frost levels so that bids don’t remain too high after the spike in battery sales has passed.

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

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



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

Grab the full code and try the script from here.

More resources:

Featured Image: Pepgooner/Shutterstock

fbq('track', 'PageView');

fbq('trackSingle', '1321385257908563', 'ViewContent', { content_name: 'troas-google-ads-script', content_category: 'pay-per-click ' });

Source link


SEO Legend, Mentor & Friend



SEO Legend, Mentor & Friend

The SEO industry will be forever changed with the loss of Bill Slawski, owner of SEO By The Sea, Director of Search at Go Fish Digital, educator, mentor, and friend.

Bill was a great many things to a lot of people. He has been a contributor here at Search Engine Journal since 2019, and a friend and mentor to many of us for decades more.

It’s not often you can say that someone has influenced and shaped an entire industry. But this is one of those times.

On May 19, 2022, the SEO industry learned that Bill Slawski had passed away.

The loss and sadness across our community were palpable.

Remembering Bill Slawski: SEO Legend, Mentor & Friend

Remembering Bill Slawski: SEO Legend, Mentor & Friend

Remembering Bill Slawski: SEO Legend, Mentor & Friend

Remembering Bill Slawski: SEO Legend, Mentor & Friend

Remembering Bill Slawski: SEO Legend, Mentor & Friend

Remembering Bill Slawski: SEO Legend, Mentor & Friend
Remembering Bill Slawski: SEO Legend, Mentor & Friend

Remembering Bill Slawski: SEO Legend, Mentor & FriendRemembering Bill Slawski: SEO Legend, Mentor & Friend

A search patent expert, colleague and mentor to many, and a friend to many more, Bill influenced the lives of everyone in the search industry.


If you hadn’t read one of the thousands of articles he wrote or contributed to, watched one of his interviews, attended one of his talks, or listened to a podcast he was a guest on – I guarantee that someone you work with, learn from, or work for has.

This was due in no small part to Bill’s vast knowledge and expertise, combined with an unequaled passion for the nuances and technological advances that make search engines tick.

I spoke with Bill a few weeks ago as we were planning a feature article on the patents he felt are most impactful for search marketers.

In that interview, he explained his love for patents.

“One thing I always say about patents is they’re the best place to find assumptions about searchers, about search, and about the web. These are search engineers sharing their opinions in addition to solving problems,” he said.

He loved getting to see what engineers were thinking, and what they had to say when it comes to different problems on the web.

“One of my favorite types of patents to look up is when they repeat a patent and file a continuation,” Bill explained. “I like to look at these continuation patents and see how they’ve changed, because they don’t tell you, ‘This is what we’re doing.’”

That innate curiosity and true passion for unraveling the complexities of the search algorithms we work with each day made talking with Bill and reading his work a real joy.


I can’t tell you how many times I’ve gone to Bill or referenced his work in mine over the years, as have so many others.

He had a real talent for making complex concepts more accessible for readers and marketers of all stripes. As a result, his contributions to our collective understanding of how search works are unrivaled.

Bill Slawski’s work and knowledge are foundational to the practice of SEO as we know it today.

I speak for all of us at SEJ in saying we’re incredibly grateful for what he generously shared with each of us.

He was a close friend and respected colleague to our founder, Loren Baker, as well.

“Bill Slawski was a true friend of mine in more ways than one. First of all, he was a surprising mentor who helped me out quite a bit early on in my career, even before the days of social media or Search Engine Journal. He was my buddy and workmate,” Loren said.

Loren Baker and Bill Slawski

Loren Baker and Bill Slawski

Bill and Loren worked together for a couple of years and spent a lot of time out in the parking lot in Havre de Grace, Maryland, smoking cigarettes and talking about Google patents.

“If anything, I would say that Bill taught me that there was much more to SEO than just ranking alone,” Loren explained, adding that Bill taught him the importance of incorporating a narrative into all of the work that you do.


“He taught me the ethics and workmanship behind creating a piece of digital art that people will want to read, will want to share, and will ultimately search for and click on–touching their lives,” he said. “I will miss Bill deeply. It’s very difficult losing friends.”

Having started in 1996 and launching SEO By The Sea in 2005, Bill was the go-to source when you wanted to understand how search engines work or how they change the way we search or live our lives.

But it was so much more than that.

Bill was generous with his time and eager to share his knowledge of search, information retrieval, NLP, and other information technology with any and all.

He had a gift for taking complex patents, algorithms, concepts, real-world behavior, and search engines and explaining how the world of search and information retrieval worked in a way that everyone could understand.

Bill seemed to have an instinct for understanding what you knew and didn’t know or where you were confused. He could fill in the gaps without making you feel silly for having asked. Even if it was the millionth time he’d answered that question.

You didn’t have to be an SEO rockstar or an experienced professional, either.

If you didn’t understand something or had questions, he would happily spend hours explaining the concepts and offering (or creating) resources to help. And as many in the industry who encountered Braggadocio can attest to, you always felt like a long-lost friend, even if you had just “met” him in text.


“It’s like when you go to a conference and you’re one of the first people there. And all the seats are still empty and there’s not a lot of discussion going on. That’s what the SEO world was like back then…I remember happening upon an SEO forum and just being a lurker. Just looking at what everybody was talking about and thinking, ‘this is a strange career. I’m not sure I can do this.’ In the end, I did it.

I started out working and promoting a website for a couple friends who started a business. And so helping them succeed in business was a pretty good motivation.” Bill Slawski, cognitiveSEO Talks interview, April 5, 2018

Bill’s wealth of knowledge extended far beyond search, too.

With a Bachelor of Arts in English from the University of Delaware and a Juris Doctor Degree from Widener University School of Law, Bill spent 14 years as a court manager, administrator, technologist, and management analyst with the Superior Court of Deleware.

He loved nature and plants, and the ocean. He loved traveling and search conferences, but he ultimately found peace in nature and took advantage of it often. And he shared it with us all.

Bill pushed everyone to look beyond the headlines and keywords.

He was quick to add words of support and congratulations when someone shared an achievement. He encouraged everyone to explore the possible, to not be intimidated by new things, and to better understand the search ecosystem, not just the technology, so we could better serve our families, communities, colleagues, and clients.

His kindness, generosity, loyalty, and love of the industry knew no bounds.

The King of Podcasts on Twitter

The King of Podcasts on Twitter

Marshall Simmonds on Twitter

Marshall Simmonds on Twitter

Here at Search Engine Journal, Bill was a familiar face on social media and a VIP contributor, but he was much more than that.

Matt Southern, News Writer

One of the things I’ll miss most about Bill Slawski is the outdoor photography he shared on Twitter.

As deeply entrenched as he was in SEO and online marketing, he always took time to step back from the keyboard and admire life’s beauty.

I think that’s something we could all benefit from doing more of.

Roger Montti, News Writer

I knew Bill Slawski for almost 20 years, from the forums and search marketing conferences. He created a stir with all the things he discovered in the patents, which went a long way toward demystifying what search engines did.

What impressed me the most was his generosity with his time and how encouraging he was to me and to everyone. I feel privileged and honored to have been able to call him a friend.


He will be profoundly missed.

Brent Csutoras, Advisor and Owner

So much of our marketing journey has been in understanding not only how something works with Google but what they are trying to accomplish over the coming years so we can be prepared and ready to pivot when needed.

Bill’s work with patents provided valuable insight very few individuals were capable of distilling and yet everyone benefited from.

He was instrumental in getting us to where we are as SEOs and digital marketers today.

Bill Slawski Was A Man Of Quiet Impact

“My first interaction with Bill Slawski was on Kim Krause Berg’s Cre8asite forum. I was trying to learn what SEO was all about, so I just lurked, soaking up knowledge from bragadocchio, Black Knight, Grumpus, Barry Welford, and others. I know that Bill started more 10,000 threads there during his time as one of the admins and one of the first things that struck me was his willingness to patiently share his knowledge. At the time, I had no idea who he was, but it quickly became obvious that he was someone who was worth listening to. ”

~ Doc Sheldon, Facebook

That he was.

Atul Gawande once wrote that life is meaningful because it has a story–one driven by a deep need to identify purposes outside of ourselves and a transcendent desire to see and help others achieve their potential.


This was the very essence of Bill’s life.

Not just in the wealth of unparalleled knowledge and resources he has gifted to us, but in the inspiration, guidance, and encouragement he has instilled in us all. That is his legacy and one that will live on.

It’s been difficult to hit Publish on this piece as I don’t feel anything we share could do that legacy justice.

Search Engine Journal will leave Bill’s library of content here untouched in perpetuity, and we’ve left comments open below for all to share your contributions to this memorial for Bill.

Thank you, Bill, for sharing your intelligence, passion, and knowledge with the SEO community.

You will be sorely missed.

Written in collaboration with Angie Nikoleychuk.



if( typeof sopp !== “undefined” && sopp === ‘yes’ ){
fbq(‘dataProcessingOptions’, [‘LDU’], 1, 1000);
fbq(‘dataProcessingOptions’, []);

fbq(‘init’, ‘1321385257908563’);

fbq(‘track’, ‘PageView’);

fbq(‘trackSingle’, ‘1321385257908563’, ‘ViewContent’, {
content_name: ‘memoriam-bill-slawski’,
content_category: ‘news seo’

Source link

See also  Why Did Your Google Business Profile Get Suspended?
Continue Reading

Subscribe To our Newsletter
We promise not to spam you. Unsubscribe at any time.
Invalid email address