開始使用

請按照下列步驟啟動第一個指令碼。

  1. 登入 Google Ads 帳戶。
  2. 按一下「工具」圖示 灰色扳手上有白色扳手,然後選取「大量操作」下方的「Scripts」
  3. 按下「+」圖示 白色加號 即可新增指令碼。
  4. 複製下列程式碼並貼到主函式中的編輯器區域:

    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()}`);
         }
    }
    
  5. 當系統出現提示時,按一下「AUTHORIZE」,讓指令碼可代您存取帳戶。您需要為每個指令碼完成一次這個步驟。

  6. 按一下「預覽」即可在預覽模式中執行指令碼。結果會顯示在「CHANGES」/「LOGS」面板中。

管理員帳戶

您必須先擁有 Google Ads 管理員帳戶,才能執行 Ads Manager 指令碼。

  1. 登入 Google Ads 管理員帳戶。
  2. 按一下「工具」圖示 灰色扳手上有白色扳手,然後選取「大量操作」下方的「Scripts」
  3. 按下「+」圖示 白色加號 即可新增指令碼。
  4. 複製下列程式碼並貼到主函式中的編輯器區域:

    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()}`);
      }
    }
    
  5. 當系統出現提示時,按一下「AUTHORIZE」,讓指令碼可代您存取帳戶。您需要為每個指令碼完成一次這個步驟。

  6. 按一下「預覽」即可在預覽模式中執行指令碼。結果會顯示在「CHANGES」/「LOGS」面板中。

如需更多指令碼片段範例,請參閱範例頁面