請按照下列步驟啟動第一個指令碼。
Google Ads 帳戶
- 登入 Google Ads 帳戶。
- 按一下「工具」圖示 ,然後選取「大量操作」下方的「Scripts」。
- 按下「+」圖示 即可新增指令碼。
複製下列程式碼並貼到主函式中的編輯器區域:
function main() { let keywords = AdsApp.keywords() .orderBy("metrics.impressions DESC") .forDateRange("YESTERDAY") .withLimit(10) .get(); console.log("The 10 keywords with the most impressions yesterday:"); for (const keyword of keywords) { console.log(`${keyword.getText()}: ${keyword.getStatsFor("YESTERDAY") .getImpressions()}`); } }
當系統出現提示時,按一下「AUTHORIZE」,讓指令碼可代您存取帳戶。您需要為每個指令碼完成一次這個步驟。
按一下「預覽」即可在預覽模式中執行指令碼。結果會顯示在「CHANGES」/「LOGS」面板中。
管理員帳戶
您必須先擁有 Google Ads 管理員帳戶,才能執行 Ads Manager 指令碼。
- 登入 Google Ads 管理員帳戶。
- 按一下「工具」圖示 ,然後選取「大量操作」下方的「Scripts」。
- 按下「+」圖示 即可新增指令碼。
複製下列程式碼並貼到主函式中的編輯器區域:
function main() { // Retrieve all children accounts. const accountIterator = AdsManagerApp.accounts().get(); // Iterate through the account list. for (const account of accountIterator) { // Get stats for the child account. const stats = account.getStatsFor("THIS_MONTH"); // And log it. console.log(`${account.getCustomerId()},${stats.getClicks()},` + `${stats.getImpressions()},${stats.getCost()}`); } }
當系統出現提示時,按一下「AUTHORIZE」,讓指令碼可代您存取帳戶。您需要為每個指令碼完成一次這個步驟。
按一下「預覽」即可在預覽模式中執行指令碼。結果會顯示在「CHANGES」/「LOGS」面板中。
如需更多指令碼片段範例,請參閱範例頁面。