Introduction to Google Ads scripts

google ads scripts

Have you heard about Google Ads Scripts? If you worked in an agency, you might be familiar with scripts. Also, if you’re running PMax, you will need a script to get more insights into campaign performance, as Google hides a lot of stuff.

 

But scripts can do a lot of stuff and help you eliminate those repetitive tasks from bidding to negative keyword exclusions to changing URLs and Search ads texts. You might be put off just by hearing the word “scripts”, but I think you should be at least familiar with what are Google Ads scripts and how they can be useful to you.

 

In this post, we will look at what Google Ads scripts are, how they are used, and how you can create your own without any programming knowledge. Yes, you heard it right.

 

 

 

What Are Google Ads Scripts?

To many, me including, just hearing the word scripts, I want to call my developer. No wonder when this is how Google defines it:

 

Google Ads scripts provide a way to programmatically control your Google Ads data using simple JavaScript in a browser-based IDE. You can use scripts to automate common procedures or interact with external data—for one to many Google Ads accounts.

 

The only word I understood was “simple”. But it’s actually not that complicated and Google loves to be too techy in describing all their products. Let’s break it down.

Google Ads scripts allow you to control data and actions in your Google Ads account using JavaScript. JavaScript is a programming language, and you don’t need to know it. It’s basically like automation rules; I wrote about them a couple of weeks ago. Scripts are just a lot more flexible.

 

You can access the Google Ads script editor in your account by going to Tools & Settings > Bulk actions > Scripts.

 

 

Most likely you won’t see any scripts there. But if you do, you have to find out who created it and what does it do. It might be an old agency or an employee. If the script is active someone can still have access to your data, or the script might perform an action that does more harm than good.

If you can’t find out what the script does. Disable it.

 

Let’s look at what Google Ads Scripts can do:

  • create ad assets
  • ad media (images) in bulk
  • manage bidding strategies, make bid adjustments
  • bulk uploads (such as uploading offline conversions)
  • create search ads
  • control ad schedule
  • manage keywords
  • exclude placements lists
  • work with negative keywords
  • Search audiences
  • manage budgets
  • campaign level targetting settings (locations, devices)
  • create drafts and experiments
  • integrate Google spreadsheets, Google Drive, charts, Email, Google Cloud (Microsoft SQL Server, MySQL)
  • Ad labels at the account, campaign, ad group, ad, and keyword levels
  • Manage Performance MAx campaigns
  • Create reports
  • Manage Google Shopping campaigns with some exceptions (like creating a Shopping campaign)
  • Manage video campaigns but can’t create them.

 

There is a lot you can do with scripts. Obviously, not everything, but what it can do is more than enough to optimize your work.

 

 

 

Benefits of Using Google Ads Scripts

 

Automation of repetitive tasks

Scripts are mostly used by agencies to automate some of the tasks they do for all accounts. If you did not know, most agency employees work on many accounts. Depending on the account size, one person can be assigned to manage up to a 100 accounts. The bigger the account, the less you can manage. This is the downside of working with an agency, as they won’t spend a lot of time actually managing your account. But that’s another story.

Saving time on repetitive tasks earns you more money. You write the script once and use it on all accounts.

 

Real-time data manipulation and reporting

Similarly, there is a lot of reporting going on. Most clients want a weekly or a monthly report, and that could take a lot of time. You get the script and only adjust the metrics to match specific businesses. You save time that can be allocated to somewhere else. Google sheets work great for that.

 

 

Enhanced bid management

This is quite a popular use case as well. If you’re on manual CPC, managing those bids can be a daunting task. But, I do recommend it when starting out. You need to get your hands dirty if you want to learn. However, it can become a time-consuming task and can be automated.

With automated bidding strategies, you have less work because you don’t manage bids for each keyword. You can create your own bidding rules with the help of scripts and stay ahead of the game.

 

 

Customized alerts and notifications

If you’re not in the account daily, you might miss some of the things happening. You can use scripts to set up emails to be sent out to specific people. For example, when the budget goes dry, email accounting. Or when sales drop, email the performance manager.

This way, you know that when something happens, appropriate people will be notified automatically. Obviously, you can set up email alerts for yourself as well.

 

 

 

 

Key Operations and Script Types

There are a lot of use cases with scripts. But from my experience, you could categorize them into a few categories. These are not official types; it just helps a bit to wrap your head around them.

 

Reporting scripts

These scripts are designed to create reports, and most of the time, you will need Google Spreadsheets. The data from your Google Ads account is exported into a link you provide.

An exception could be if you’re sending data to a different platform where the analysis takes place. Then, you will need to add how the script passes that information to a third-party platform. This is way beyond my capabilities, I know it’s possible and I just outsource this task.

 

Bidding scripts

You don’t need anything extra here. These scripts help you manage keyword bids in your account based on various signals. For example, you could write a script that lowers the bids of each keyword if the cost is above $50 and there are no conversions. You can also pause the keywords or increase the bids if it performs well.

Here, you need clearly defined rules when you need to change the bidding. And sometimes, it is trickier than it sounds.

 

Alert scripts

Anything you want to schedule as an email falls here. Notify someone about the dropping sales or increased spending. Or just send a daily/weekly/monthly report.

 

Bulk operation scripts

Change the final URL, find/update broken links, update text ads, upload images and videos, and replace stuff. If you need to do it for the whole account, it might take a while. For example, say your landing page changed, and you have 500 ads. You can do it with the script. That’s a one-time thing, but it still saves you time. But what if you need to upload images constantly or update text ads?

Having a script to manage bulk operations is a huge time saver for many agencies. Depending on your account size, you can benefit as well.

 

 

Getting (buying) Google Ads scripts from third parties

You might be wondering how you can get a script if you can program, and I did say that you won’t need that. Well, most of the scripts can be purchased. Sometimes, they are offered for free.

 

For example, Mike Rhodes writes a lot of scripts and is trusted by a lot of people on LinkedIn. You can buy this PMax script from his website and just implement it in your account.

Most of his reporting scripts require connecting a Google Spreadsheet link, which is easy. There is a place in the script you have to amend. But I will show you that later.

 

I’ve downloaded one of his free scripts on PMax.

 

 

It’s not as pretty as you might expect. He might have a newer version that is nicer. But when I analyze stuff I don’t care about the looks. I need the data. I have only two PMax campaigns, but I see the distribution by network cost etc. There are many tabs in this sheet I can explore. I think his paid script has a lot more stuff.

 

There are also many people who sell scripts, but I haven’t Googled a lot about it. I usually prefer to order a script by going to Fiverr.com or Upwork.com. This allows me to customize the script the way I want it. But I’m not saying that ready-made scripts are less powerful. If you see that you need what the script does and it helps you optimize your time, then get it.

 

The only word of caution is to make sure the script is legit. Basically, it’s similar to anything else you buy online. Make sure you will get the script after paying. Check for reviews and examples of that script or other scripts. Usually, people working with scripts have a blog or are active on LinkedIn.

 

 

Prebuilt scripts

Google Ads also has some script templates you can use. There isn’t a lot to choose from, but could be a great intro into scripts.

 

 

Account anomaly detector script. Sends out an email when your account performance deviates significantly.

Link Checker script. Check if any of your links produce a “page not found” error.

Account summary script. You can generate a simple report of your account’s performance.

Ad Performance script. This is a report of your ads. You can get a Google spreadsheet with various distribution charts showing how your ads perform.

Flexible Budget script. You can use it to adjust the campaign budget dynamically. Adjusting the daily spend might help equally distribute your money.

Common negative list script. You can add negative keywords to a list. Simplifies things.

 

You can also customize those scripts. But I would suggest creating a new one, especially if you don’t know JavaScript. You could just ruin the whole thing.

 

 

Using chatGPT to write custom scripts

Let’s talk about how you can create your own script. Unless you know JavaScript, we will be using AI to help us out. I don’t know how to code at all. But as I said, you don’t need to.

Before we jump into chatGPT, we need to define what we want the script to do. Let’s start with a task everyone should be doing at least on a weekly basis – check search term reports for poorly performing keywords.

 

When I check the report, I look for keywords that have a high spend and no conversions. I check if I can pause them or reduce the bid. If you’re on automated bidding, your option is only to pause the keyword.

 

Based on what I want, this is what the script should do:

  • Check the Search term report for each keyword
  • Find keywords that have more than 100 clicks and 0 conversions
  • Add those keywords as negatives
  • If keywords have 1 or more converions, check if CPA is above 20€, then reduce the CPC by 20%

So I went to chatGPT  and wrote, “Can you generate a Google Ads script based on these inputs?” and just listed what I wrote above. This is the first versions:

 

Just like, to you, it means nothing. I don’t understand the code. But I don’t need to. Obviously, there is a little risk, but there is a way to test the script. Later about that.

 

I’ve tested it and realized it was missing a few things. I wanted to create a list of negative keywords so I can check it and see if something was not added by mistake. I also wanted to exclude campaigns with automated bidding strategies. So I asked for an update.

 

Update the script with these changes:

  • Ignore campaigns that are on automated bidding strategies
  • instead of adding negative keywords, create a negative keyword list named “script negatives” and add those keywords to this list
  • then apply the list to a campaign where this negative keyword was found in

 

Here’s the final version. You can copy if you want:

 

function main() {
var THRESHOLD_CLICKS = 100;
var THRESHOLD_CONVERSIONS = 0;
var CPA_THRESHOLD = 20; // In your currency
var REDUCE_CPC_PERCENTAGE = 0.20; // 20%
var NEGATIVE_KEYWORD_LIST_NAME = "script negatives";

// Check if the negative keyword list already exists
var negativeKeywordListIterator = AdsApp.negativeKeywordLists()
.withCondition('Name = "' + NEGATIVE_KEYWORD_LIST_NAME + '"')
.get();

var negativeKeywordList;
if (negativeKeywordListIterator.hasNext()) {
negativeKeywordList = negativeKeywordListIterator.next();
} else {
// Create the negative keyword list if it doesn't exist
negativeKeywordList = AdsApp.newNegativeKeywordListBuilder()
.withName(NEGATIVE_KEYWORD_LIST_NAME)
.build()
.getResult();
}

// Iterate through keywords
var keywordIterator = AdsApp.keywords()
.withCondition("Clicks > " + THRESHOLD_CLICKS)
.forDateRange("LAST_30_DAYS")
.get();

while (keywordIterator.hasNext()) {
var keyword = keywordIterator.next();
var campaign = keyword.getCampaign();
var biddingStrategy = campaign.getBiddingStrategyType();

// Ignore campaigns with automated bidding strategies
if (biddingStrategy !== "MANUAL_CPC" && biddingStrategy !== "MANUAL_CPV") {
continue;
}

var stats = keyword.getStatsFor("LAST_30_DAYS");
var conversions = stats.getConversions();
var cpa = stats.getCost() / (conversions === 0 ? 1 : conversions); // Avoid division by zero
var currentBid = keyword.bidding().getCpc();

if (conversions === THRESHOLD_CONVERSIONS) {
// Add keyword to the shared negative keyword list
negativeKeywordList.addNegativeKeyword(keyword.getText());
// Apply the list to the campaign
campaign.addNegativeKeywordList(negativeKeywordList);
Logger.log("Added negative keyword to list and applied to campaign: " + keyword.getText());
} else if (conversions > THRESHOLD_CONVERSIONS && cpa > CPA_THRESHOLD) {
// Reduce CPC by 20%
var newBid = currentBid - (currentBid * REDUCE_CPC_PERCENTAGE);
keyword.bidding().setCpc(newBid);
Logger.log("Reduced CPC for keyword: " + keyword.getText() + " to new bid: " + newBid);
}
}
}

 

You can also add an alert to this script. When you list the requirements for the script, you can add “send an email to your@email.com when changes were made”. This way, you can send an email to yourself if the script made any changes.

 

Now we can take this script and go to the Google Ads account to implement it.

 

 

Setting Up Your First Script

In your account, go to Tools & Settings > Bulk actions > Scripts. Click to create a new script. You should see a blank page. Delete everything and paste the script you copied from me or from where you got it. Give it a descriptive name so you know what it does.

 

 

Now, you have to click on Preview to make sure it works. You will have to authorize the script, so make sure you have the right access to the account. Once you authorize it, the script will run and give you the results.

The preview just lists what will happen if you run the script. So make sure you see what you want.

 

You might see no changes because the script hasn’t made any, which is not bad. It just means that whatever the criteria you set did not match anything, no changes were made.

It might also give you some errors. If you bought the script, you can ask the creator how to fix them. If you created it through chatGPT, you can also ask how to fix the error. You shouldn’t see any errors for simple scripts.

Once you’re sure the script works, you can run it and then save it. Now, go back to the Scripts in the menu. You will see your script, and you can adjust the frequency of this script.

 

 

Depending on your account, you may want it to run weekly or monthly. Always check what has been done after you run the script for the first time. For this list specifically I asked to create a negative keyword list and add keywords there. So I go to the list and check if at least the list was created, since that’s what I saw in the preview.

 

 

I see that the list was created, and no keywords were added. That is good. If there were keywords, I would go and check what keywords were added and then go to the Search Term report to see how this keyword was performing and make sure there were no mistakes.

 

 

 

Frequently asked questions

 

What are Google Ads scripts?

Google Ads scripts let you automate and manage your Google Ads using simple JavaScript in a web-based editor. These scripts make it easier to handle complex tasks and integrate with other data sources for your advertising campaigns. More often than not, they increase PPC performance.

 

What do I need to start using Google Ads scripts?

You would need access to a Google Ads account and a script. The script can be purchased as a ready-made solution, created by a developer (your own or outsourced), or created using AI software like chatGPT.

 

Are paid scripts better than free?

Not necessarily. Simple scripts can be free and good. A more complicated script will rarely be free because it takes a lot of time to create it.

 

What do I need to know to create a script on my own?

You need JavaScript programming language. It is possible to learn it, but if you only need a Google Ads script, then it might be a waste of time. Find a developer on Fiverrr.com or Upwork.com

 

How many scripts can I have in my Google Ads account?

The limit is 250 authorized scripts per account.

 

Are there MCC (MY Client Center) scripts?

Yes. It works the same way; it just resides under an MCC account and not under individual Google Ads Accounts.