预览模式

当脚本在预览模式下执行时,它们不会更改实际的 广告系列数据。相反,脚本执行会显示原本会发生 所发生的更改对输出结果感到满意后 可以立即开始或安排脚本实际执行。

预览模式是一项强大的功能,可让您开发和调试脚本,而无需担心对 Google Ads 数据进行错误更改。

预览模式仅会影响使用 AdsApp 作为入口点的调用。调用 其他服务将照常运行。例如,如果脚本使用 MailApp 来发送电子邮件,那么无论脚本是否已 预览或执行的数据。在上述两种情况下,电子表格也会更新。脚本可以通过 执行信息

以下代码段将无法在预览模式下按预期运行:

// Suppose the ad group has no keywords.
let adGroup = findAnEmptyAdGroup();

// Create a keyword.
adGroup.createKeyword("test");

// Fetch all keywords in the ad group.
let keywords = adGroup.keywords().get();

// In preview mode, will log "false": keyword was not actually created.
// In real execution, will log "true".
console.log("Are there keywords in the ad group? " + keywords.hasNext());