進階 API
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Google Ads 腳本中的進階 API 可讓經驗豐富的開發人員連線至特定公開 Google API,設定程序比使用 HTTP 介面更簡便。您使用這些 API 的方式與指令碼的內建服務非常相似,而且這些 API 也提供自動完成和自動授權等便利功能。
進階 API 的可能用途
- Google Analytics 4
- 您可以使用 Google Analytics 4 追蹤網站流量,並據此調整廣告活動出價。連結 Google Analytics 4 資源和 Google Ads 帳戶後,您也可以分析網站上的顧客活動。並透過這項資料瞭解 Google Ads 為您的網站帶來了多少人潮或銷售量,再據以改善廣告和網站。如要進一步瞭解如何連結 Analytics 和 Google Ads 帳戶,請參閱這篇 Google Analytics 4 說明文章。
- Google BigQuery
- 您可以將大量資料載入 Google Cloud Storage,然後使用 Google BigQuery 查詢該資料。舉例來說,您可以載入過去 10 年的公開天氣資料,然後在指令碼中查詢某個區域的平均溫度,並根據這項資訊調整出價。另一個用途是針對帳戶過去幾年的成效資料進行數字運算。
- YouTube 和 YouTube 數據分析
- 您可以擷取及更新影片、播放清單等,以及影片的成效資料,以便做出出價決策。
- Google 日曆
- 指令碼可以為日後的工作建立活動 (例如,在 2 週後為廣告活動執行成效報表),也可以根據您在日曆中建立的項目執行動作 (例如,在特定日期啟用廣告活動)。
- 購物內容
- 您的指令碼可以在 Apps Script 中使用 Google Content API for Shopping。Google Merchant Center 使用者可透過這項 API 上傳及管理產品資訊,並管理 Merchant Center 帳戶。在指令碼中,這項功能可用於檢查產品資訊,並將特定產品連結至特定廣告。
- Google Tasks
- 指令碼可以建立未來工作的提醒清單 (例如,在兩週後執行廣告活動的成效報表),或根據提醒清單中建立的項目執行動作 (例如,在特定日期啟用廣告活動)。
- Google 簡報
- 指令碼可將廣告活動詳細資料或統計資料匯出至 Google 簡報,以可呈現的格式發布這類資訊。
啟用進階 API
如要查看哪些 Google API 可做為進階 API,請按一下頂端編輯器列的「進階 API」按鈕。

這時會顯示「進階 API」對話方塊。勾選要啟用的 API。

接著,按一下「Google API 控制台」連結,在控制台中開啟「API 控制台」頁面,並顯示與指令碼相關聯的專案。如果尚未選取專案,請從「專案」下拉式清單中選取。在搜尋列中輸入 API 名稱,即可搜尋要在指令碼中使用的 API。

在搜尋結果中選取 API,然後在下一個頁面選擇「啟用」。如果看到「停用」按鈕,表示這個 API 已啟用。針對要啟用的每個 API 重複執行這個動作。

如要查看專案已啟用的 API 清單,請選取「資訊主頁」頁面。確認您要用於指令碼的所有進階 API 都已列出。

現在請關閉「進階 API」對話方塊,返回編輯器。系統會為指令碼啟用新的 API,並顯示在自動完成清單中。

可用的 API
您可以使用下列 API:
您也可以參閱程式碼片段頁面,瞭解如何使用這些 API。
最後請思考:
使用進階 API 時,請注意下列事項。
專案 ID
每個 Google Ads 指令碼都與一個 Google Cloud 專案 ID (也稱為專案編號) 相關聯。如要查看指令碼的專案編號,請從「進階 API」對話方塊開啟 Google API 控制台頁面。這個專案 ID 會在您建立指令碼時建立,並與建立 Google Ads 指令碼的使用者相關聯。如果建立指令碼的使用者稍後從帳戶中移除,嘗試存取指令碼的使用者會收到提示,要求重新授權指令碼,並再次設定進階 API 依附元件。系統也會建立新的 Google 開發人員專案 ID,您需要重新設定進階 API,如本文稍早所述。
依附元件
只有在帳戶中建立指令碼的使用者,才能變更該指令碼的進階 API 依附元件。
權限
存取 API 時,指令碼會使用授權指令碼的使用者權限。請確認授權指令碼的使用者具備所有進階 API 的必要存取權,以及指令碼所需的資料。如果您使用 Google Analytics API,請確認授權指令的使用者具備存取 Analytics 帳戶的必要權限。
條款及細則
各項進階 API 可能有各自的條款及細則,您在 Google API 控制台中啟用 API 時,應接受這些條款及細則。
配額
大多數進階 API 都提供免費每日配額。如果指令碼超出配額,API 就會停止運作,直到您要求額外資料或免費配額補充完畢為止。如要監控指令碼使用的配額,請從「進階 API」對話方塊開啟指令碼的 Google API 控制台。您也可以透過 Google API 控制台,要求增加 API 配額。
帳單
部分進階 API 需要付費才能使用。這些款項是透過與指令碼相關聯的 Google Cloud 專案管理,而非透過 Google Ads。如要進一步瞭解如何為指令碼的 Google Cloud 專案啟用帳單功能,請參閱說明文件。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eAdvanced APIs in Google Ads scripts allow experienced developers to connect to public Google APIs like Google Analytics, BigQuery, YouTube, and more with simplified setup.\u003c/p\u003e\n"],["\u003cp\u003eThese APIs offer conveniences such as auto-completion and automatic authorization, similar to built-in scripts services.\u003c/p\u003e\n"],["\u003cp\u003eTo enable Advanced APIs, users need to select them in the script editor, enable them in the Google API Console, and ensure the authorized user has necessary permissions.\u003c/p\u003e\n"],["\u003cp\u003eScripts utilize the authorized user's permissions and are subject to each API's terms, conditions, quotas, and potential billing for usage.\u003c/p\u003e\n"],["\u003cp\u003eEach script has an associated Google Cloud Platform Project ID, tied to the creator, which might require reauthorization and setup if the creator is removed from the account.\u003c/p\u003e\n"]]],[],null,["# Advanced APIs\n\nThe advanced APIs in Google Ads scripts let experienced developers connect\nto certain public Google APIs with less setup than using their HTTP interfaces.\nYou use these APIs much like scripts' built-in services, and they offer the same\nconveniences like auto-completion and automatic authorization.\n\nPossible uses for Advanced APIs\n-------------------------------\n\nGoogle Analytics 4\n: You can use Google Analytics 4 to track the traffic coming to your website and\n adjust your campaign bids accordingly. If you link a Google Analytics 4 property\n to your Google Ads account, you can also analyze customer activity on your\n website. This information can shed light on how much of your website traffic or\n sales comes from Google Ads and help you improve your ads and website. You can\n learn more about linking Analytics and Google Ads accounts through\n [Google Analytics 4](//support.google.com/analytics/answer/10089681).\n\nGoogle BigQuery\n: You can load large quantities of data into Google Cloud Storage, and then\n query that data using Google BigQuery. For example, you can load public weather\n data for the past 10 years and then query for a region's average temperature in\n a script that uses that information in adjusting bids. Another use would be to\n do number crunching over your account's performance data over several years.\n\nYouTube and YouTube Analytics\n: You can retrieve and update your videos, playlists, etc. as well as your\n videos' performance data to make bidding decisions.\n\nGoogle Calendar\n: Your script can create events for future tasks (for example, run a\n performance report for your campaigns 2 weeks from today), or perform actions\n based on an entry you created on your calendar (for example, enable a campaign\n on a specific date).\n\nShopping Content\n: Your script can use the Google Content API for Shopping in Apps Script. This\n API gives Google Merchant Center users the ability to upload and manage their\n product listings and manage their Merchant Center accounts. In scripts, this\n can be useful to check product listings and link specific products to specific\n ads.\n\nGoogle Tasks\n: Your script can create a reminder list for future tasks (for example, run a\n performance report for your campaigns two weeks from today), or perform actions\n based on an entry you created in your reminder list (for example, enable a\n campaign on a specific date).\n\nGoogle Slides\n: Your script can export campaign details or statistics to Google Slides to\n publish such information in a presentable format.\n\nEnable Advanced APIs\n--------------------\n\nTo see which Google APIs are available as advanced APIs, click the **Advanced\nAPIs** button on the top editor bar.\n\nThis brings up the **Advanced APIs** dialog. Check the APIs you want to enable.\n\nNext, click the **Google API Console** link to bring up the **API Console**\npage in the Console, with the project associated with your script; or, if\nyour project is not already selected, select it from the Project drop-down\nlist. Search for the APIs you want to use in your script by entering the API\nname in the search bar.\n\nIn the search results, select the API, and on the following page choose\n**Enable** ; if you see a **Disable** button, then this API is already\nenabled. Repeat this action for each API you want to enable.\n\nTo view the list of enabled APIs for the project, select the **Dashboard**\npage. Verify that all the Advanced APIs you want to use for the script are\nlisted.\n\nNow close the Advanced APIs dialog to return to your editor. The new APIs\nwill be enabled for your script and available in the autocomplete list.\n\nAvailable APIs\n--------------\n\nThe following APIs are available for use:\n\n| API Name | Documentation |\n|-------------------|-----------------------------------------------------------------------------------------------------------------|\n| Google Analytics | [https://developers.google.com/apps-script/advanced/analytics](/apps-script/advanced/analytics) |\n| Google BigQuery | [https://developers.google.com/apps-script/advanced/bigquery](/apps-script/advanced/bigquery) |\n| Google Calendar | [https://developers.google.com/apps-script/advanced/calendar](/apps-script/advanced/calendar) |\n| Google Slides | [https://developers.google.com/apps-script/advanced/slides](/apps-script/advanced/slides) |\n| Google Tasks | [https://developers.google.com/apps-script/advanced/tasks](/apps-script/advanced/tasks) |\n| Shopping Content | [https://developers.google.com/apps-script/advanced/shopping-content](/apps-script/advanced/shopping-content) |\n| YouTube | [https://developers.google.com/apps-script/advanced/youtube](/apps-script/advanced/youtube) |\n| YouTube Analytics | [https://developers.google.com/apps-script/advanced/youtube-analytics](/apps-script/advanced/youtube-analytics) |\n\nYou can also refer to our [code snippets page](/google-ads/scripts/docs/examples)\nfor some examples on how to use these APIs.\n\nFinal considerations\n--------------------\n\nThere are a few things to keep in mind when working with the Advanced APIs.\n\n### Project ID\n\nEach Google Ads script has a Google Cloud\n[Project ID](//support.google.com/cloud/answer/6158853)\n(also known as a project number) associated with it. You can find your script's\nproject number by opening the Google API Console page from the **Advanced APIs**\ndialog. This project ID is created when you create the script, and is tied to\nthe user who created the Google Ads script. If the user who created the script\nis later removed from the account, then a user trying to access the script will\nbe prompted to reauthorize the script and setup Advanced API dependencies again.\nA new Google Developer Project ID will also be created, and you will need to\nsetup the Advanced APIs again, as explained earlier in this document.\n\n### Dependencies\n\nOnly the user who created the script in the account can change the Advanced\nAPIs dependencies for that script.\n\n### Permissions\n\nWhen accessing the APIs, a script uses the permissions of the user who\nauthorized the script. Make sure that the user who authorized the script has the\nrequired access to all Advanced APIs being used as well as the data the script\nneeds. If you are using the Google Analytics API, verify that the user who\nauthorized the script has the necessary permissions for the Analytics account\nbeing accessed.\n\n### Terms and Conditions\n\nEach of the Advanced APIs may have its own Terms and Conditions which you\nshould accept when enabling the API in the Google API Console.\n\n### Quota\n\nMost Advanced APIs have a free daily quota associated with it. Once your script\nexceeds this quota, the API will stop working until you request additional\ndata, or the free quota is replenished. You can\n[monitor](//support.google.com/cloud/answer/6158858) the quota used by your\nscript by opening the Google API Console for the script from the **Advanced\nAPIs** dialog. The Google API Console also provides you a way to request\nadditional quota for the API.\n\n### Billing\n\nSome Advanced APIs require you to pay for usage. These payments are managed\nthrough the Google Cloud project associated with your script, and not through\nGoogle Ads. See our\n[documentation](//support.google.com/cloud/answer/6158867) for more details on\nhow to enable billing for your script's Google Cloud project."]]