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.
This script automatically identifies and excludes placements (not YouTube URLs) that aren't meeting the view threshold you've set for 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:
- Find statistics on video performance, specifically view rate, for the given campaign over the past week.
- 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 can modify the script to use a set of parameters that you value more highly when evaluating placements.
Parameters
The only parameter in this script is VIEW_RATE_THRESHOLD
. It specifies the
target percentage of times users view the ad. Placements under this threshold
are to be excluded.
Setup
- Create a new script with the source code below.
- Update
VIEW_RATE_THRESHOLD
in the pasted code. - Examine the criteria used to determine when to exclude a placement, and update them if necessary.
- Schedule the script to run 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/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;
}