Google's Display targeting isn't known for it's qualitative placements. Quite often you will find irrelevant websites or websites with foreign domain extensions in your Display placement report. This script will give you more control of your placement quality by hourly excluding placements which do not meet your criteria. It does this in two ways:

  1. Excluding all placements which contain words you have selected. If, for example, you do not want your ads to show on viral websites, you can add 'viral' to the array in the exWords variable.
  2. Including placements containing relevant domain extensions. If you want your ads to show only on .nl domains you add this to the placementSelector as shown.

Note: this script might be inefficient for larger campaigns.

Script
/***
  * Adgroup level auto keyword excluder *
  
  Script by Bas Baudoin for happyleads.nl
  
  About the script: the script has 2 functions, it includes ONLY placements
    containing certain string(s) and it excludes placements that contain
    other string(s).
  Instructions:
  You can modify 3 things in this script:
  1. Date range         (line 20)
  2. Strings to exclude (line 23)
  3. Strings to include (line 46)
  Schedulde hourly
  
***/

// (Modify 1.) Use official adwords scripts date range formatting
var dateRange = 'LAST_30_DAYS'

// (Modify 2.) Exclude placements containing:
var exWords = ['wordfeud',
               'haber',
               'game',
               'viral']

// Main function, do not change
function main() {
  includeOnly()
 
  // (this is inefficient)
  for (var i in exWords) {
    excludeContaining(exWords[i])
  }
}

// Include only function
function includeOnly() {
  var placementSelector = AdsApp.display()
     .placements()
     .withCondition("Impressions > 1")
    
  // (Modify 3.) exclude placements that do not contain
  // use same formatting as below
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.nl'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.com'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.net'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.org'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.nu'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.be'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.de'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.google'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.info'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.tv'")
  
     .forDateRange(dateRange)
     .orderBy("Clicks DESC")

 // Add negative placement
  var placementIterator = placementSelector.get()
  while (placementIterator.hasNext()) {
    var placement = placementIterator.next()
    var adgroup = placement.getAdGroup()
    var placeUrl = placement.getUrl()
      var placementBuilder = adgroup.display().newPlacementBuilder()
     .withUrl(placeUrl)
     .exclude()
   Logger.log('Excluded placement: ' + placeUrl)
  }
}

// Exclude function, runs for each exWord
function excludeContaining(dotext) {

  // Select placements
  var placementSelector = AdsApp.display()
  .placements()
  .withCondition("Impressions > 1")
  .withCondition("PlacementUrl CONTAINS '" + dotext + "'")
  .forDateRange(dateRange)
  .orderBy("Clicks DESC")
  
  // Add negative placement
  var placementIterator = placementSelector.get()
  while (placementIterator.hasNext()) {
    var placement = placementIterator.next()
    var adgroup = placement.getAdGroup()
    var placeUrl = placement.getUrl()
    var placementBuilder = adgroup.display().newPlacementBuilder()
    .withUrl(placeUrl)
    .exclude()
    Logger.log('Excluded placement: ' + placeUrl)
  }
}

Sharing knowledge

Adsscripts.com is all about sharing knowledge. In the current market, PPC specialists like to keep their knowledge and experience to themselves. We're convinced that sharing knowledge can ensure that everyone gets better at their work. We want to change this by sharing our knowledge about scripts with everyone.

Do you also want to contribute? We are open to new ideas and feedback on everything you find on Adsscripts.com.

Contact us

Nils Rooijmans
Google Ads Scripter
Water Cooler Topics
Nils Rooijmans, Google Ads Scripter
Bas Baudoin
Teamleader PPC
Happy Leads
Bas Baudoin, Teamleider SEA
Tibbe van Asten
PPC Specialist
Founder Adsscripts
Tibbe van Asten, Senior PPC Automation Specialist