Automatic Placement Exclusion

Sometimes there are videos which have a different target audience than your ads, but you might not know that until you start accruing stats. Once you see that a specific placement just isn't performing the way you want, you can eliminate it from your targeting.

The Automatic Placement Exclusion script allows you to automatically identify and exclude placements that just aren't resulting in the views you'd expect on your video ads.

Scheduling

The script considers the last 7 days of statistics. Schedule it to run Weekly.

How it works

For each campaign in your account, the script runs through the same process.

  1. Find statistics on video performance, specifically view rate, for the given campaign over the past week.
  2. For each URL under a specific threshold of view rate (configurable), add a targeting exclusion for that placement to prevent your ads from showing there anymore.

If view rate is not the most important statistic for you, you should take a stab at updating the script to use a set of parameters that you value more highly when determining which placements do and don't work for you.

Parameters

The only parameter in this script is VIEW_RATE_THRESHOLD. It specifies the target percentage of times that people view your ad through. Placements under this threshold will be excluded.

Setup

  • Create a new script with the source code below.
  • Don't forget to update VIEW_RATE_THRESHOLD in the pasted code.
  • Take a careful look at the conditions used to determine when to exclude a placement, and consider updating them to stats that may be more relevant for your business.
  • Schedule the script Weekly.

Source Code

// Copyright 2016, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


/**
 * @name Automatic Placement Exclusions
 *
 * @overview The Automatic Placement Exclusions script analyzes the
 *     performance of your video ads across various placements, and then
 *     automatically excludes them from appearing for URLs that have
 *     underperformed based on VideoViewRate.
 *     See
 *     https://developers.google.com/adwords/scripts/docs/solutions/automatic-placement-exclusions
 *     for more details.
 *
 * @author AdWords Scripts Team [adwords-scripts@googlegroups.com]
 *
 * @version 1.0
 *
 * @changelog
 * - version 1.0
 *   - Released initial version.
 */


// The view rate under which placements will be automatically excluded.
var VIEW_RATE_THRESHOLD = '10.00%';

// Exclude any placements that don't have at least this many impressions in the
// last 7 days to reduce noise.
var MIN_IMPRESSIONS = 50;

function main() {
  VIEW_RATE_THRESHOLD = parseFloat(VIEW_RATE_THRESHOLD);
  var results = getReportResults();
  var ids = [];
  for (var id in results) {
    ids.push(id);
  }
  var videoCampaignIterator = AdWordsApp.videoCampaigns()
      .withIds(ids)
      .get();
  while (videoCampaignIterator.hasNext()) {
    var videoCampaign = videoCampaignIterator.next();
    var id = videoCampaign.getId();
    if (results.hasOwnProperty(id)) {
      var urls = results[id];
      for (var i = 0; i < urls.length; i++) {
        videoCampaign.videoTargeting().newPlacementBuilder()
            .withUrl(urls[i])
            .exclude();
      }
    }
  }
}


function getReportResults() {
  var query = 'SELECT CampaignId, Url' +
    ' FROM URL_PERFORMANCE_REPORT' +
    ' WHERE Impressions >= ' + MIN_IMPRESSIONS +
    ' AND VideoViewRate < ' + (VIEW_RATE_THRESHOLD / 100) +
    ' DURING LAST_7_DAYS';
  var report = AdWordsApp.report(query);
  var rows = report.rows();
  var results = {};
  while (rows.hasNext()) {
    var row = rows.next();
    var campaignId = row['CampaignId'];
    var url = row['Url'];
    if (!results.hasOwnProperty(campaignId)) {
      results[campaignId] = [];
    }
    if (results[campaignId].indexOf(url) < 0) {
      results[campaignId].push(url);
    }
  }
  return results;
}

Send feedback about...

AdWords Scripts
AdWords Scripts