預覽模式

指令碼在預覽模式下執行時,對實際的廣告活動資料不會產生任何變更。而是會顯示指令碼執行後「可能」所進行的變更。對輸出內容感到滿意之後,您就可以開始執行指令碼或安排執行時間。

預覽模式是一項強大的功能,可讓您開發指令碼並進行偵錯,不用擔心對 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());