skip to Main Content
Excluding Placements Using A Script

Placement Exclusion Script – Google Display Ads

We use numerous scripts to improve advertiser performance across Google’s Display Network (GDN). One of the quickest steps to making Google Display Network (GDN) more effective is through the use of a Placement Exclusion Script. In this post we describe a basic version of this Google Ads script to automatically block underperforming placements across display ads.

What does the script do?

The script will collect performance metrics by placement URL and, based upon defined thresholds, add the URL to a defined Placement Exclusion List. Thresholds can be changed to suit advertiser requirements, with an exclusion based on a set amount of minimum impressions, conversion rate, and clicks.

What are the benefits?

Poorly performing placements (in this case websites) will be automatically excluded at desired intervals. As a result, this will reduce wasted budget, lead to an improved conversion rate and therefore ROAS (Return on Ad Spend) allowing accounts to scale! Even better, the exclusion list can be used across other campaigns or accounts assisting those too.

All that said, we strongly recommend previewing the results of this script before pushing to a live advertiser account. This can be done in the script tool within Google Ads.


  1. Create a Placement Exclusion List and apply it to the display campaigns you want to improve.
    In our example we created one called Auto Placement (Scripts) – Performance. If you create one with a different name you must update the script to reflect that.
  2. Change thresholds.
    Towards the top of the script you’ll be able to set the following thresholds which must all be met to exclude a placement:
    • MIN_IMPRESSIONS – the minimum impressions a placement must have to be examined by the script
    • MIN_CLICKS – the minimum number of clicks a placement must have to be examined by the script
    • CONV_RATE_THRESHOLD – the minimum conversion rate acceptable to you, the advertiser

      Using the default thresholds, any placement which has 25 or more clicks, 50 or more impressions and a conversion rate below the threshold of 10% will be excluded by adding it to the desired Placement Exclusion List.
  3. Add the script and set the interval but, as above, ensure you preview what the script will do before pushing it onto a live environment.

The full Placement Exclusion Script

This placement exclusion script is free to use and a good starting point for anyone using GDN already who has a simple conversion account setup. For more complicated scripts or for assistance buying traffic, contact us.

 * @name Automatic Placement Exclusion for Display Ads 
 * @overview The Automatic Placement Exclusions script analyzes the
 *     performance of your display ads across various placements, and then
 *     automatically excludes them from appearing for URLs that have
 *     underperformed based on Clicks, Conversions and Impressions.
 * Hat-tip to the Google Ads Scripts Team, based upon
 * @author
 * @version 1
 * @changelog
 * - version 1.0
 *   - Released initial version.


	//Ignore placements which don't meet the following thresholds:
	var MIN_CLICKS = 25;
	//The conversion rate under which placements will be automatically excluded
	var CONV_RATE_THRESHOLD = '10.00%';
	//--Define your Placement Exclusion List which you must create separately--
	var excludedPlacementList = "Auto Placement (Scripts) - Performance";

//--End Setup--

function main() {
  var results = getReportResults();
  var ids = [];
  for (var id in results) {

  //remove .withCondition("Status = ENABLED") to work on all display campaigns, not just enabled ones
  var displayIterator = AdsApp.campaigns().withCondition("Status = ENABLED").withCondition("AdvertisingChannelType = DISPLAY").get(); 

  while (displayIterator.hasNext()) {
    var displayCampaign =;
    var id = displayCampaign.getId();
    if (results.hasOwnProperty(id)) {
      var urls = results[id];
      for (var i = 0; i < urls.length; i++) {
          var sharedSet = AdsApp.excludedPlacementLists().withCondition("Name = '"+excludedPlacementList+"'").get().next();

function getReportResults() {
  var query = 'SELECT CampaignId, Domain' +
    ' WHERE Impressions >= ' + MIN_IMPRESSIONS +
    ' AND Clicks >= ' + MIN_CLICKS +
    ' AND ConversionRate < ' + (CONV_RATE_THRESHOLD / 100) +
  var report =;
  var rows = report.rows();
  var results = {};
  while (rows.hasNext()) {
    var row =;
    var campaignId = row['CampaignId'];
    var url = row['Domain'];
    if (!results.hasOwnProperty(campaignId)) {
      results[campaignId] = [];
    if (results[campaignId].indexOf(url) < 0) {
  return results;

Further Reading

If you would like to change the time frame the script considers, replace ‘LAST_7_DAYS’ inside the query with any of the following:

  • LAST_14_DAYS
  • LAST_30_DAYS

For a script to block placements which yield poor view-rate on video ads, see Google’s example here.

Disclaimer: Whilst we’ve researched and tested methods in this post and elsewhere on this website, care should be taken when automating any part of online advertising. This information is made available for educational purposes only and provided ‘as is’, no representations are made that the content is error-free. Furthermore, things often change at Bing, Google et al and another person/team may interpret/implement things differently with unexpected outcomes. We, as the company and individuals within it, will not be held responsible for any damages or losses through the use of such methods or advice on this website or elsewhere.

Use Google Ads Scripts at your own risk.

This Post Has 5 Comments

    1. Thanks Daniel. We’ll look to upload some more free Google Ads scripts in the coming weeks, is there anything in particular you’d like to see?

  1. Hi

    Getting this error:
    “Cannot retrieve the next object: iterator has reached the end. (file, line 52)”

    1. This would occur if the Placement Exclusion List is either not yet created (go to Tools at the top of the Google Ads dashboard, select ‘Placement exclusion lists’ under the heading ‘Shared Library’ to create one) OR not correctly referenced in the code – look for the following line:

      var excludedPlacementList = "Auto Placement (Scripts) - Performance";

      In our example the Placement Exclusion List is called Auto Placement (Scripts) – Performance, ensure the script references whatever you have called yours.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top