Preview:
function main() {
  // Settings
  var campaignName = "Campaign Name"; 
  var negativeKeywordListName = "Auto-Generated Negatives";
  var dateRange = "LAST_30_DAYS";

  // Find or create the negative keyword list
  var negativeKeywordList = AdsApp.negativeKeywordLists().withCondition("Name = '" + negativeKeywordListName + "'").get().next();
  if (!negativeKeywordList) {
    negativeKeywordList = AdsApp.newNegativeKeywordListBuilder()
      .withName(negativeKeywordListName)
      .build()
      .getResult();
  }

  // Get search query data 
  var queryReport = AdsApp.searchQueryPerformanceReport()
      .forCampaign(campaignName)
      .withCondition("Status = ENABLED") // Focus on active keywords
      .during(dateRange);

  var queryRows = queryReport.rows();
  while (queryRows.hasNext()) {
    var queryRow = queryRows.next();
    var searchQuery = queryRow.getQuery();
    var impressions = queryRow.getImpressions();
    var clicks = queryRow.getClicks();
    var cost = queryRow.getCost();

    // Add query as a negative keyword if it meets your criteria 
    // Example: High impressions, low CTR, high cost
    if (impressions > 100 && clicks == 0 && cost > 10) {
      negativeKeywordList.addNegativeKeyword(searchQuery);
    } 
  }

  // Apply the negative keyword list to the campaign
  var campaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next();
  campaign.addNegativeKeywordList(negativeKeywordList);
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter