Display placement exclusion script not working

306 views
Skip to first unread message

Henry Croft

unread,
Jun 21, 2022, 1:39:30 PM6/21/22
to Google Ads Scripts Forum
Hi

I am trying to get the following script to work but it keeps finishing with "no changes".

Please advise, thanks.

----

/***
  * 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 = ['game',
               'kids',
               '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 '.com'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.net'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.org'")
     .withCondition("PlacementUrl DOES_NOT_CONTAIN '.co.uk'")
     
 
     .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)
  }
}

Google Ads Scripts Forum

unread,
Jun 27, 2022, 5:32:03 AM6/27/22
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/NPBz0yh6BNY) from the forum as it wasn't routed to our support queue.

Regards,
Teejay
Google Ads Scripts Team

Google Ads Scripts Forum Advisor

unread,
Jun 27, 2022, 11:33:37 PM6/27/22
to adwords...@googlegroups.com

Hello,

I’m James from the Google Ads scripts support team. Thank you for reaching out to us.

Can you please share with us the following information below so that I can take a closer look and conduct some troubleshooting?

  • Google Ads account ID / CID
  • Script name
  • Also, can you confirm if you're experiencing the said behavior upon executing your script using the new script experience or via Legacy version?

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2cDTKh:ref

Henry Croft

unread,
Jun 28, 2022, 10:45:31 AM6/28/22
to Google Ads Scripts Forum
Hi

ID: 285-645-0184
Script name: Display excluder
I've tried the script with both versions and encounter the same issue.

Thanks

Google Ads Scripts Forum

unread,
Jul 27, 2022, 12:07:16 AM7/27/22
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/NPBz0yh6BNY) from the forum as it wasn't routed to our support queue.

Regards,
Yasmin
Google Ads Scripts Team

Google Ads Scripts Forum Advisor

unread,
Jul 27, 2022, 3:46:22 PM7/27/22
to adwords...@googlegroups.com
Hello,

Thanks for providing the requested information. I can see that the placement selector on line 38 is retrieving an empty set of placements. It's possible that no placements match the specified conditions. Please also note that the placement selector will only fetch managed placements. The old Google Ads Scripts experience returns both managed and automatic placements. If you wish to retrieve automatic placements you must use AdsApp.search or AdsApp.report and request the detail_placement_view.

Regards,

Google Logo
Matt
Google Ads Scripts Team
 

 

ref:_00D1U1174p._5004Q2cDTKh:ref
Reply all
Reply to author
Forward
0 new messages