Automatically manage exclusions with this bad placement cleaner script

Feb 10, 2020 | Search Engine Optimization News

Fighting bad placements in Google’s display network can be a daunting task for many. Especially when performance reviews and placement exclusions are done manually. But this account level script can lessen some of the pain points and help advertisers save money by automatically excluding bad placements.

These are the problems the script is trying to solve:

  1. Exclusions of bad placements based on domain endings
  2. Exclusions of bad placements in standard display campaigns
  3. Exclusions of bad placements in video campaigns
  4. Exclusions of bad placements in mobile apps

It sounds like a perfect script, right? Well, there are some limitations you should be aware of:

  1. Google Ads scripts cannot really modify any “smart” campaigns – so if you run Smart Shopping Campaigns OR Smart Display campaigns, you are out of luck until Google adds support for modifying these campaign types as well.
  2. Google Ads scripts cannot exclude specific YouTube channels nor profiles. Again, this is a limitation of the scripting environment as of now. Essentially, the script helps to exclude bad video placements outside YouTube.
  3. Google Ads scripts can only exclude entire domains, not their subpages so the script can exclude but not
  4. If your campaigns contain commas in their name, the script will fail.

So what does the script exactly do? 

The shorter version:

  1. The script identifies bad placements
  2. The script creates exclusions lists
  3. The script assigns the exclusions lists to campaigns

The longer version:

  1. The script loads the values from your config spreadsheet.
  2. The script runs placement performance report for “today” – this is for the domain ending exclusion module.
  3. The script identifies all placements matching all your unwanted domain endings and adds them to the exclusion list.
  4. The script downloads campaign performance data in order to determine what’s a Display and what’s a Video campaign.
  5. The script runs two placement performance reports – one for Display, one for Video. The results are separately exported to your config spreadsheet.
  6. The results are aggregated for each placement on account level – regardless of its campaign and adgroup. If you click around the config sheet, you will see sheets with these aggregations after you run the script.
  7. Once aggregations are done, the script filters for bad placements according to your configuration. You can check out the results of the filtering after the script finishes running – just visit the config spreadsheet. The sheet names are pretty self-explanatory.
  8. Finally, the filtered tables are the lists of “bad placements.”
  9. The script creates four exclusion lists – one for Domain Endings, one for Display, one for Video, one for Apps.
  10. The exclusions lists are filled with bad placements (in case bad placements are found).
  11. Enabled Display campaigns are assigned with Domain Endings, Display, and App exclusion list.
  12. Enabled Video campaigns are assigned with Domain Endings, and Video exclusion list.

It’s important to mention that the config spreadsheet is heavily used during the evaluation process. There are many helper sheets created and clicking through the helper sheets will give you a better idea of how exactly the script works.

Running the script

These are the steps you need to take before running the script:

  1. Create a configuration spreadsheet by visiting
    The best practice is to have one configuration spreadsheet for one account.
  2. Setup the configuration spreadsheet. Basically, go row by row and define which modules of the script you actually want to run (Domain Endings, Display, Video, Apps) and define your thresholds.
  3. Get the code of the script here:
  4. Paste the code of the script into Google Ads script console.
  5. Enter spreadsheet ID of your configuration spreadsheet into ssId variable in the script.
  6. Run the script, approve all the needed scopes. Do not run the script in the preview mode – the script will likely fail because it needs exclusion lists to exist at the latter stages and the lists are not created in the preview mode.
  7. Schedule the script – probably anywhere from hourly to weekly cadence.

Threshold definitions

It’s important to understand how to define the thresholds correctly – in other words – how to define bad placements. You can see that example in the Display module. You have a variety of metrics available for the definition of bad placements:

automatically-manage-exclusions-with-this-bad-placement-cleaner-script Automatically manage exclusions with this bad placement cleaner script

You need to realize that all metrics are applied. So even if you don’t really care about all the metrics, you need to set threshold correctly for all the metrics anyway so the conditions can be met for the metrics you care about. 

With this being said, the above example would exclude all placements with CTR higher than 90% (and the remaining metrics >= 0 would always fit too).

This is how the rule for the exclusion of all mobile placements would like:

automatically-manage-exclusions-with-this-bad-placement-cleaner-script-1 Automatically manage exclusions with this bad placement cleaner script

As soon as a mobile placement gets one impression, the script will add that placement to the exclusion list.

What do I do if I don’t like the results?

Locate the exclusion lists in your Google Ads account, then remove all the assigned campaigns, and then remove the list. These steps will take you back “before the script period.” It’s that simple. 


The script runs more than 30 minutes and fails

automatically-manage-exclusions-with-this-bad-placement-cleaner-script-2 Automatically manage exclusions with this bad placement cleaner script

It’s possible that your account is simply too big. Try increasing the impression threshold and shortening the lookback window at the top of the configuration spreadsheet.

The config spreadsheet grows too big and the script fails

The same solution as above.

Sheet ID XYZ does not exist

A random error you may encounter without a clear cause. It’s usually a temporary problem in Google Sheets. Re-running the script should help.

Other errors

If you encounter a new error, contact me directly at


The script is not perfect but it can still save you tons of your advertising dollars. While the configuration may be a little more complicated at first sight, it will get much easier with every subsequent account.

Opinions expressed in this article are those of the guest author and not necessarily Search Engine Land. Staff authors are listed here.

About The Author

automatically-manage-exclusions-with-this-bad-placement-cleaner-script Automatically manage exclusions with this bad placement cleaner script
Daniel Zrust works as digital analytics lead in Avast. His main areas of focus are paid search, automation, and analytics. In his free time, he publishes articles to his blog where he covers tips’n’tricks for BigQuery, Google Ads Scripts, Power Query or pretty much anything which can make your PPC lives easier.


eHost managed wordpress hosting

We’re listening.

Have something to say about this article? Share it with us on Facebook, Twitter or LinkedIn:


Subscribe ToThe Weekly SEO Trade News Updates

Get the latest SEO, SEM and SMM marketing intel, tips and tricks from one of the best SEO Gurus online. 

Every Tuesday morning we send out an aggregated email listing all new posts on SEO Trade News.

Excellent! Now check your email to confirm your subscription.