AdWords
2.2K members online now
2.2K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

Script Help, Query not recognizing column name?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there, I am trying to modify the placement exclusion script for Youtube but am running into an issue with it not recognizing the column name or does not like my input. I am basically trying to exclude any placements that have spent > $25 and have 0 conversions. I have two variables: One for cost (MIN_COST) and one for conversion threshold (Zero_Con). Something in the query from the URL performance report does not like the conversion column even though that is a valid column title. 

 

Any help is appreciated!

 

 

 

var Zero_Con = '1.00';
var MIN_COST = 25;

function main() {
  Zero_Con = parseFloat(Zero_Con);
  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 Cost >= ' + MIN_COST +
    ' AND Conversions < ' + Zero_Con +
    ' DURING LAST_14_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;
}

 

1 Expert replyverified_user

Script Help, Query not recognizing column name?

Rising Star
# 2
Rising Star

Good morning.

 

Scripts can be tricky, it's true. I would suggest that you try posting your question in the help forum for scripts.


Theresa
Google AdWords Top Contributor
*~*~*~*~*~*~*~*