外部数据集成
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
重要数据(商品目录、转化等)通常位于 Google Ads 网域之外。同样,Google Ads 界面可能并不总是数据可视化的理想工具。Google Ads 脚本提供了一种与外部数据源轻松集成的方式。
Google 电子表格
Google 电子表格(位于 Google 云端硬盘中)是一款功能全面的基于网络的电子表格解决方案。借助 Google Ads 脚本,您可以通过 Spreadsheet Service 读取电子表格中的数据并向其中写入数据。您还可以通过编程方式创建电子表格、向其中填充数据、设置字体和颜色格式,以及与他人分享该电子表格。您可以在脚本中通过以下方式使用它们:
- 报告可视化
- 电子表格提供各种类型的图表。您可以设置一个包含图表的电子表格来直观呈现数据,然后从脚本导入数据源以自动更新图表。
- 数据源
- 您可以创建电子表格,在其中手动输入数据(或输入来自其他来源的数据)。然后,脚本可以读取并处理数据,以更新您的账号。例如,您可以将新关键字输入到电子表格中,然后通过每日运行的脚本将其添加到您的账号中。
- 中间数据存储
- 电子表格可以在运行时存储有关其执行状态的信息,以便在下次执行时从上次停止的地方继续执行。例如,如果您需要处理账号中的所有广告组,但处理时间超过了 30 分钟的执行时间限制,则可以在处理过程中记录已处理的广告组。当脚本再次执行时,它可以检查电子表格以确定从何处开始,从而避免重复执行任何工作。
Google 云端硬盘
您还可以通过 DriveApp
进一步利用 Google 云端硬盘,该服务可让脚本在 Google 云端硬盘中创建、查找和修改任意文件。如前所述,这可用作数据源或中间数据存储区。
图表
您还可以通过图表服务使用增强型数据可视化功能。这项功能全面的图表构建服务可让您根据自己的数据可视化需求进行广泛的控制。
JDBC
您可以连接到外部 JDBC 兼容数据库,例如 Google Cloud SQL、MySQL、Microsoft SQL Server 和 Oracle 数据库。如需查看设置说明,请参阅本指南。
电子邮件
借助 Google Ads 脚本,您可以通过 Mail Service 发送电子邮件。电子邮件可用于通知您脚本中需要的所有相关信息;例如,通过电子邮件发送包含完整报告链接的摘要。您可以使用自定义 HTML 自定义电子邮件,甚至可以添加图片,从而使脚本能够直接向客户发送专业外观的报告。您可以使用附件发送大型报告。
抓取网址
借助 Google Ads 脚本,您可以使用 网址 Fetch 服务提取任意网址的内容。此功能可带来多种机会:
- 在您的网站上设置受密码保护的 Feed,用于报告商品目录信息。然后,通过 Google Ads 脚本访问该文件,以便应用账号更改。
- 获取有关外部事件的信息,并根据这些信息做出账号管理决策。例如,您可以从基于 HTTP 的 API 中提取天气信息,并在目标区域下雨时调整出价或启用广告。
- 网络上提供了各种各样的 API;任何具有 HTTP 接口的 API 都可以访问。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-27。
[null,null,["最后更新时间 (UTC):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."]]