請按照下列步驟啟動第一個指令碼。
- 登入 Google Ads 帳戶。
- 按一下「工具」圖示
,然後選取「大量操作」下方的「指令碼」。
- 按下「+」圖示
新增指令碼。
複製下列程式碼,然後貼到編輯器區域內的主函式中:
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()}`); } }
出現提示時,按一下「授權」,指令碼便可存取 管理。您必須為每個指令碼分別進行一次。
按一下「預覽」,即可在預覽模式中執行指令碼。系統會顯示結果 在「變更 / 記錄」面板中。
您需要先有一位 Google Ads 經理 帳戶,以便執行 Google Ads Manager 指令碼
- 登入 Google Ads 管理員帳戶。
- 按一下「工具」圖示
,然後選取「大量操作」下方的「指令碼」。
- 按下「+」圖示
即可新增 指令碼
複製下列程式碼,然後貼到編輯器區域內的主函式中:
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()}`); } }
出現提示時,按一下「授權」,指令碼便可存取 管理。您必須為每個指令碼分別進行一次。
按一下「預覽」,即可在預覽模式中執行指令碼。結果會顯示在「變更」/「記錄檔」面板中。
如需更多指令碼範例,請參閱範例 頁面。