外部資料整合集成
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
重要資料 (例如:目錄和轉換) 通常位於 Google Ads 網域之外。同樣地,Google Ads 使用者介面可能不一定是資料視覺化的最佳工具。Google Ads 腳本可輕鬆與外部資料來源整合。
Google 試算表
Google 試算表 (位於 Google 雲端硬碟) 是功能齊全的網路試算表解決方案。透過 Google Ads 腳本,您可以透過 Spreadsheet Service 讀取及寫入試算表。您也可以透過程式輔助建立試算表、填入資料、設定字型和顏色格式,以及與他人共用試算表。您可以在指令碼中透過下列方式使用這些函式:
- 報表視覺呈現
- 試算表提供多種圖表。你可以設定含有圖表的試算表,將資料視覺化,然後從指令碼匯入資料來源,自動更新圖表。
- 資料來源
- 您可以建立試算表,然後手動輸入資料 (或從其他來源輸入資料)。然後指令碼可以讀取及處理資料,以更新帳戶。舉例來說,您可以將新關鍵字輸入試算表,然後透過每日執行的指令碼新增至帳戶。
- 中間資料儲存
- 試算表在執行時可以儲存執行狀態的相關資訊,以便在下次執行時從中斷處繼續。舉例來說,如果您需要處理帳戶中的所有廣告群組,但所需時間超過 30 分鐘的執行時間限制,可以記錄處理的廣告群組。當指令碼再次執行時,可以檢查試算表,找出開始處理的位置,避免重複作業。
Google 雲端硬碟
您可以使用
DriveApp
進一步運用 Google 雲端硬碟,讓指令碼在 Google 雲端硬碟中建立、尋找及修改任意檔案。如先前所示,這可用做資料來源或中繼資料儲存空間。
圖表
您也可以透過 Charts Service 取得強化資料視覺化功能。這項功能齊全的圖表建立服務可讓您全面掌控資料視覺化需求。
JDBC
您可以連線至符合 JDBC 標準的外部資料庫,例如 Google Cloud SQL、MySQL、Microsoft SQL Server 和 Oracle 資料庫。如需設定操作說明,請參閱這份指南。
電子郵件
Google Ads 腳本可讓您透過 Mail Service 傳送電子郵件。您可以使用電子郵件通知自己腳本中的任何相關資訊,例如郵寄摘要並附上完整報告的連結。您可以使用自訂 HTML 來自訂電子郵件訊息,甚至加入圖片,讓指令碼直接將專業報表傳送給客戶。附件可用於傳送大型報表。
網址擷取
Google Ads 腳本可讓您使用 URL Fetch 服務擷取任意網址的內容。這項功能可帶來多種好處:
- 在網站上設定受密碼保護的動態饋給,回報商品目錄資訊。然後透過 Google Ads 指令碼存取,以便套用帳戶變更。
- 擷取外部事件的相關資訊,並根據這些資訊做出帳戶管理決策。舉例來說,您可以從以 HTTP 為基礎的 API 擷取天氣資訊,並在指定地區下雨時調整出價或啟用廣告。
- 網路上有各種 API 可供使用,只要有 HTTP 介面就能存取。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[[["\u003cp\u003eGoogle Ads Scripts facilitates integration with external data sources for enhanced data analysis and automation.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Sheets, Drive, and Charts services can be used for data visualization, storage, and reporting within Google Ads Scripts.\u003c/p\u003e\n"],["\u003cp\u003eExternal databases and custom web applications can be connected to Google Ads Scripts via JDBC and URL Fetching services.\u003c/p\u003e\n"],["\u003cp\u003eEmail functionality enables automated notifications and reporting based on script outputs.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Ads Scripts empowers users to programmatically control and automate Google Ads campaigns with external data and services.\u003c/p\u003e\n"]]],[],null,["# External Data Integration\n\nImportant data (inventory, conversions, etc.) often reside outside the Google\nAds domain. Likewise, the Google Ads UI may not always be the perfect\ntool for data visualization. Google Ads scripts provide an easy way to\nintegrate with external data sources.\n\nGoogle Spreadsheets\n-------------------\n\nGoogle Spreadsheets (found in [Google Drive](//drive.google.com)) are a\nfull-featured web-based spreadsheet solution. Google Ads scripts lets you read\nfrom and write to spreadsheets through the\n[Spreadsheet Service](/apps-script/reference/spreadsheet). You can also\nprogrammatically create a spreadsheet, populate it with data, format its fonts\nand colors, and share it with others. Some of the ways you can use them in your\nscripts include:\n\nReport visualization\n: Spreadsheets offer various types of charts. You can set up a spreadsheet with\n a chart to visualize your data, and then import the data source from a script to\n automatically update the chart.\n\nData source\n: You can create a spreadsheet where you manually input data (or input data\n from some other source). A script can then read and process the data to update\n your account. For example, you can enter new keywords to a spreadsheet that are\n then added to your account by a daily running script.\n\nIntermediate data store\n: A spreadsheet can store information about its execution state as it runs, so\n that it can pick up where it left off on the next execution. For example, if\n you need to process all ad groups in your account but it takes longer than the\n [30 minute execution time limit](/google-ads/scripts/docs/limits), you can\n record the ones you process as you go. When the script executes again, it can\n check the spreadsheet to figure out where to start so it doesn't duplicate any\n work.\n\nGoogle Drive\n------------\n\nYou can further leverage Google Drive with\n[`DriveApp`](/apps-script/reference/drive/drive-app) which lets scripts create,\nfind, and modify arbitrary files on Google Drive. This can be used as a data\nsource or intermediate datastore as previously shown.\n\nCharts\n------\n\nEnhanced data visualization is also available through the\n[Charts Service](/apps-script/reference/charts). This full-fledged chart\nbuilding service gives you extensive control over your data visualization\nneeds.\n\nJDBC\n----\n\nYou can connect to external JDBC-compliant databases such as Google Cloud SQL,\nMySQL, Microsoft SQL Server, and Oracle databases. See [this\nguide](/apps-script/guides/jdbc) for set-up instructions.\n\nEmail\n-----\n\nGoogle Ads scripts let you send out emails through the\n[Mail Service](/apps-script/reference/mail). Email can be used for\nnotifying yourself of any pertinent information you need from the script; for\nexample, mailing out a summary with a link to a full report. You can customize\nthe email message with custom HTML and even add images, allowing the script to\nsend professional-looking reports directly to your clients. Attachments can be\nused to send large reports.\n\nURL fetching\n------------\n\nGoogle Ads scripts let you fetch the content of an arbitrary URL using the\n[Url Fetch Service](/apps-script/reference/url-fetch). This feature opens\nup a range of opportunities:\n\n- Set up a password-protected feed on your website that reports inventory information. Then, access it through a Google Ads script in order to apply account changes.\n- Fetch information about external events and make account management decisions based on that information. For example, you could fetch weather information from an HTTP-based API and adjust bids or enable ads whenever it's raining in your target area.\n- There are a wide variety of APIs available across the web; anything that has an HTTP interface is accessible."]]