A Google Ads script that pauses keywords below a target ROAS over a rolling window and logs each action to a Google Sheet.

// Pause Low-ROAS Keywords — Google Ads script
var TARGET_ROAS = 3.0;      // pause below this
var LOOKBACK_DAYS = 30;     // rolling window
var LABEL = 'auto-paused-low-roas';

function main() {
  var to = new Date();
  var from = new Date(to.getTime() - LOOKBACK_DAYS * 864e5);
  var range = Utilities.formatDate(from, AdsApp.currentAccount().getTimeZone(), 'yyyyMMdd') +
              ',' + Utilities.formatDate(to, AdsApp.currentAccount().getTimeZone(), 'yyyyMMdd');

  var kws = AdsApp.keywords()
    .withCondition('Status = ENABLED')
    .forDateRange(range)
    .withCondition('Conversions > 0')
    .get();

  while (kws.hasNext()) {
    var kw = kws.next();
    var stats = kw.getStatsFor(range);
    var roas = stats.getConversionValue() / Math.max(stats.getCost(), 0.01);
    if (roas < TARGET_ROAS) {
      kw.pause();
      kw.applyLabel(LABEL);
    }
  }
}
1 langSchedule: Daily