Placement level scripts

88 views
Skip to first unread message

jamie...@gmail.com

unread,
Jul 3, 2018, 6:18:46 AM7/3/18
to AdWords Scripts Forum
Hi everyone.

I have recently tried to use the attached script to place poorly performing placements from a Video campaign (YouTube placements) onto the exclusion list. It returned an error about not being able to target YouTube Websites for the exclusion list. Is there a way around this?

Best.

Jamie
SOLD OUT TEST.txt

Anthony Madrigal

unread,
Jul 3, 2018, 3:17:55 PM7/3/18
to AdWords Scripts Forum
Hi Jamie,

Can you please provide your CID and the name of the script so I can investigate further?

Thanks,
Anthony
AdWords Scripts Team

jamie...@gmail.com

unread,
Jul 4, 2018, 11:44:10 AM7/4/18
to AdWords Scripts Forum
Hi Anthony,

Thank you for your reply, the CID is 904-142-7980. 

Script below

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

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

function main() {
  VIEW_RATE_THRESHOLD = parseFloat(VIEW_RATE_THRESHOLD);
  var results = getReportResults();
  var ids = [1457546302];
  for (var id in results) {
    ids.push(id);
  }
  var videoCampaignIterator = AdWordsApp.videoCampaigns()
      .withIds(ids)
      .get(1457546302);
  while (videoCampaignIterator.hasNext()) {
    var videoCampaign = videoCampaignIterator.next();
    var id = videoCampaign.getId(1457546302);
    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;
}

jamie...@gmail.com

unread,
Jul 4, 2018, 11:45:00 AM7/4/18
to AdWords Scripts Forum
Script is named  "Fastlove Test"

Hiroyuki Miyauchi (AdWords Scripts Team)

unread,
Jul 5, 2018, 3:01:43 AM7/5/18
to AdWords Scripts Forum
Hello Jamie,

The reason why you are encountering the error (YOUTUBE_URL_UNSUPPORTED) is because YouTube urls are not supported in Placement criterion. You would need to use YouTubeChannel and YouTubeVideo criterion instead. You may refer to this guide to see the error descriptions.

Please let me know if you have further clarifications.

Regards,
Hiroyuki
AdWords Scripts Team

jamie...@gmail.com

unread,
Jul 5, 2018, 5:45:52 AM7/5/18
to AdWords Scripts Forum
Hi Hiroyuki,

Thank you for the reply. Is it possible to pause YouTube placements using YouTubeVideo criterion?

Best,

Jamie

Hiroyuki Miyauchi (AdWords Scripts Team)

unread,
Jul 6, 2018, 2:12:00 AM7/6/18
to AdWords Scripts Forum
Hello Jamie,

Unfortunately, pausing VideoPlacement is not supported in AdWords Scripts at this time.

You may follow our blog for any upcoming features and updates.
Reply all
Reply to author
Forward
0 new messages