內容比對刊登位置排除

工具圖示

有時,有些影片的目標對象與您的廣告不同,但您可能要等到開始累積統計資料時才會知道。如果發現特定刊登位置的成效不如預期,您可以將其從指定目標中排除。

這段指令碼會自動找出並排除不符合影片廣告觀看門檻的刊登位置 (而非 YouTube 網址)。

排程

指令碼會考量過去 7 天的統計資料。執行時段排定為每週執行。

運作方式

針對帳戶中的每個廣告活動,指令碼都會執行相同的程序:

  • 找出特定廣告活動過去一週的影片成效統計資料,尤其是收視率。
  • 針對低於特定收視率門檻 (可設定) 的網址,為該刊登位置新增指定目標排除項目,避免廣告繼續顯示。

如果收視率不是您最重視的統計資料,則可將指令碼修改為評估刊登位置時價值較高的一組參數。

參數

這個指令碼中唯一的參數是 VIEW_RATE_THRESHOLD。藉此指定使用者觀看廣告的目標百分比。系統將排除未達這個門檻的刊登位置。

設定

  • 使用下方的原始碼建立新指令碼。
  • 在貼上的程式碼中更新 VIEW_RATE_THRESHOLD
  • 檢查用來決定排除刊登位置的條件,並視需要更新。
  • 排定指令碼每週執行。

原始碼

// 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/google-ads/scripts/docs/solutions/automatic-placement-exclusion
 *     for more details.
 *
 * @author Google Ads Scripts Team [adwords-scripts@googlegroups.com]
 *
 * @version 2.0
 *
 * @changelog
 * - version 2.0
 *   - Updated to use new Google Ads scripts features.
 * - version 1.0
 *   - Released initial version.
 */


// The view rate under which placements will be automatically excluded.
let 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.
const MIN_IMPRESSIONS = 50;

function main() {
  VIEW_RATE_THRESHOLD = parseFloat(VIEW_RATE_THRESHOLD);
  const results = getReportResults();
  const ids = [];
  for (const id in results) {
    ids.push(id);
  }
  const videoCampaignIterator = AdsApp.videoCampaigns()
      .withIds(ids)
      .get();
  for (const videoCampaign of videoCampaignIterator) {
    const id = videoCampaign.getId();
    if (results.hasOwnProperty(id)) {
      const urls = results[id];
      for (const url of urls) {
        videoCampaign.videoTargeting().newPlacementBuilder()
            .withUrl(url)
            .exclude();
      }
    }
  }
}

function getReportResults() {
  const query = `SELECT campaign.id, ` +
        `detail_placement_view.target_url ` +
        `FROM detail_placement_view ` +
        `WHERE metrics.impressions >= ${MIN_IMPRESSIONS} ` +
        `AND metrics.video_view_rate < ` +
        `${(VIEW_RATE_THRESHOLD / 100)} ` +
        `AND segments.date DURING LAST_7_DAYS`;
  const report = AdsApp.report(query);
  const rows = report.rows();
  const results = {};
  for (const row of rows) {
    const campaignId = row['campaign.id'];
    const url = row['detail_placement_view.target_url'];
    if (!results.hasOwnProperty(campaignId)) {
      results[campaignId] = [];
    }
    if (results[campaignId].indexOf(url) < 0) {
      results[campaignId].push(url);
    }
  }
  return results;
}