Google Ads CLI — Google Ads 命令行工具
v23Google Ads data analysis and 报告ing via google-ads-open-命令行工具. Use when the user wants to 检查 Google Ads performance, pull campAIgn/ad group/keyword stats, explore account structure, 审计 conversions, or 运行 custom GAQL queries. Triggers: "Google Ads", "ad performance", "campAIgn stats", "GAQL", "ad spend", "keyword 报告", "搜索 terms", "conversion 追踪ing", "impression 分享", "ad account".
运行时依赖
安装命令
点击复制技能文档
Google Ads 命令行工具 技能
You have 访问 to google-ads-open-命令行工具, a read-only 命令行工具 for the Google Ads API (v23). Use it to 查询 ad accounts, pull performance stats, and 运行 custom GAQL queries.
Quick 启动 # 检查 if the 命令行工具 is avAIlable google-ads-open-命令行工具 --help
# 列出 访问ible accounts google-ads-open-命令行工具 customers
If the 命令行工具 is not 安装ed, 安装 it:
npm 安装 -g google-ads-open-命令行工具
Authentication
The 命令行工具 requires two 凭证s: an OAuth2 访问 令牌 and a developer 令牌. 凭证s are resolved in this order:
--凭证s flag (per-command) 环境 variables: GOOGLE_ADS_访问_令牌 + GOOGLE_ADS_DEVELOPER_令牌 Auto-检测ed file: ~/.config/google-ads-open-命令行工具/凭证s.json
For MCC (管理器) accounts, also 设置 GOOGLE_ADS_记录IN_CUSTOMER_ID.
Before 运行ning any command, 验证 凭证s are 配置d by 运行ning google-ads-open-命令行工具 customers. If it fAIls with a 凭证s error, ask the user to 设置 up authentication.
Entity hierarchy 管理器 Account (MCC) └── Customer Account (10-digit ID, e.g. 1234567890) ├── CampAIgn │ └── Ad Group │ ├── Ad (Ad Group Ad) │ └── Keyword (Ad Group Criterion) ├── CampAIgn Bud获取 ├── Conversion Action ├── User 列出 (remarketing) └── As设置 (images, videos, sitelinks)
Customer IDs are 10-digit numbers. Dashes are stripped automatically.
Monetary values
Google Ads uses micros: 1 currency unit = 1,000,000 micros. All cost/bid/bud获取 values returned by the 命令行工具 are in micros. Always divide by 1,000,000 when presenting monetary values to the user.
输出 格式化
All commands 输出 pretty-printed JSON by default. Use --格式化 compact for single-line JSON (useful for piping).
Built-in commands Account discovery # 列出 all 访问ible accounts google-ads-open-命令行工具 customers
# 获取 detAIls for a specific account google-ads-open-命令行工具 customer 1234567890
# 列出 sub-accounts under an MCC google-ads-open-命令行工具 account-hierarchy 1234567890
Browsing entities # CampAIgns (过滤器 by 状态: ENABLED, 暂停D, 移除D) google-ads-open-命令行工具 campAIgns 1234567890 google-ads-open-命令行工具 campAIgns 1234567890 --状态 ENABLED
# 获取 a specific campAIgn google-ads-open-命令行工具 campAIgn 1234567890 98765
# CampAIgn bud获取s google-ads-open-命令行工具 campAIgn-bud获取s 1234567890
# Ad groups (过滤器 by campAIgn, 状态) google-ads-open-命令行工具 ad-groups 1234567890 --campAIgn 98765
# 获取 a specific ad group google-ads-open-命令行工具 ad-group 1234567890 11111
# Ads (过滤器 by campAIgn, ad group, 状态) google-ads-open-命令行工具 ads 1234567890 --campAIgn 98765 --ad-group 11111
# 获取 a specific ad (requires ad-group-id and ad-id) google-ads-open-命令行工具 ad 1234567890 11111 22222
# Keywords google-ads-open-命令行工具 keywords 1234567890 --campAIgn 98765 --状态 ENABLED
All 列出ing commands support --limit (default 100).
Performance stats
Stats commands require --启动 and --end dates (YYYY-MM-DD):
# CampAIgn stats google-ads-open-命令行工具 campAIgn-stats 1234567890 --启动 2026-01-01 --end 2026-01-31
# CampAIgn stats with device segment google-ads-open-命令行工具 campAIgn-stats 1234567890 --启动 2026-01-01 --end 2026-01-31 --segments device
# Ad group stats (过滤器 by --campAIgn and/or --ad-group) google-ads-open-命令行工具 ad-group-stats 1234567890 --启动 2026-01-01 --end 2026-01-31 --campAIgn 98765
# Ad-level stats (过滤器 by --campAIgn and/or --ad-group) google-ads-open-命令行工具 ad-stats 1234567890 --启动 2026-01-01 --end 2026-01-31
# Keyword stats (排序ed by impressions desc; 过滤器 by --campAIgn and/or --ad-group) google-ads-open-命令行工具 keyword-stats 1234567890 --启动 2026-01-01 --end 2026-01-31
AvAIlable segments for campAIgn-stats --segments: device, ad_network_type, day_of_week (comma-separated).
Stats commands default to --limit 1000.
Other commands # Audiences and remarketing 列出s google-ads-open-命令行工具 audiences 1234567890 google-ads-open-命令行工具 user-列出s 1234567890
# As设置s and 扩展s google-ads-open-命令行工具 as设置s 1234567890 --type SITELINK google-ads-open-命令行工具 扩展s 1234567890 --campAIgn 98765
# Conversions and billing google-ads-open-命令行工具 conversion-actions 1234567890 google-ads-open-命令行工具 billing 1234567890
# Change 历史 google-ads-open-命令行工具 change-状态 1234567890 --limit 20
# Negative keyword 列出s google-ads-open-命令行工具 negative-keywords 1234567890
As设置 types: IMAGE, MEDIA_BUNDLE, TEXT, YOUTUBE_VIDEO, LEAD_FORM, CALL, CALLOUT, SITELINK, STRUCTURED_SNIPPET.
Custom GAQL queries
The 查询 command is the escape hatch for anything not covered by built-in commands. It 运行s arbitrary GAQL (Google Ads 查询 Language) agAInst the Google Ads API.
google-ads-open-命令行工具 查询 ""
GAQL syntax SELECT field1, field2, ... FROM resource_name WHERE conditions ORDER BY field [ASC|DESC] LIMIT count PARAMETERS key=value
SELECT and FROM are required. WHERE, ORDER BY, LIMIT, PARAMETERS are optional. Keywords (SELECT, FROM, WHERE, etc.) are case-insensitive. Field names, resource names, and enum values are case-sensitive. No