執行紀錄
Google Ads 指令碼會在預覽模式和實際執行時顯示兩種執行記錄:變更記錄和記錄輸出內容。
- 變更紀錄
變更記錄會顯示指令碼對 Google Ads 實體所做的所有變更:實體說明、變更類型、變更前後的值,以及錯誤 (如果有):

變更紀錄可以進一步篩選為只顯示錯誤。
- 記錄輸出內容
如果您在指令碼中執行 console.log("Hello world!");
,記錄中就會顯示「Hello world!」。在偵錯期間記錄文字位元特別實用,但在實際執行期間也經常很有幫助。假設下列指令碼已排定每天執行:
let spreadsheet = SpreadsheetApp.create("Daily Report");
// Populate the spreadsheet.
// ...
console.log("Daily report ready!");
console.log(spreadsheet.getUrl());
每次執行時,指令碼都會記錄新建立試算表的網址,方便日後查找。您也可以使用 console.warn()
或 console.error()
,在記錄檔中記錄橘色或紅色的文字。
除了程式設計師指定的記錄訊息外,Google Ads 指令碼在執行期間遇到的錯誤和警告也會顯示在文字記錄中。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-03-04 (世界標準時間)。
[null,null,["上次更新時間:2025-03-04 (世界標準時間)。"],[[["Google Ads scripts provide two types of execution logs: Changes logs (tracking entity modifications) and Logs output (displaying script messages)."],["Changes logs detail all alterations made by the script to Google Ads entities, including before and after values, and can be filtered to show only errors."],["Logs output displays messages generated by the script using `console.log`, `console.warn`, and `console.error`, useful for debugging and providing context during live executions."],["Errors and warnings encountered by scripts during execution are automatically included in the text logs for troubleshooting."]]],[]]