Google Ads Access for OpenClaw
Use the Google Ads API to pull campaign data, performance metrics, and account information from Google Ads accounts through an OpenClaw agent.
Configuration
Set these environment variables (typically in ~/.openclaw/load-keys.sh or similar):
GOOGLE_ADS_DEVELOPER_TOKEN- Your Google Ads API developer tokenGOOGLE_ADS_CLIENT_ID- OAuth client ID from Google CloudGOOGLE_ADS_CLIENT_SECRET- OAuth client secret from Google CloudGOOGLE_ADS_REFRESH_TOKEN- OAuth refresh token (obtained via authentication script)GOOGLE_ADS_MANAGER_ACCOUNT_ID- Your Google Ads Manager Account ID (optional, for MCC access)GOOGLE_ADS_CLIENT_ACCOUNT_ID- Specific client account ID to query (optional)
Quick Start
1. Install Dependencies
pip3 install google-ads google-auth-oauthlib google-auth
2. Authenticate
Run the authentication script to get a refresh token:
python3 scripts/authenticate.py
This will output a refresh token. Add it to your environment:
export GOOGLE_ADS_REFRESH_TOKEN="your-refresh-token-here"
3. Test Connection
python3 scripts/get_account_summary.py --account YOUR-ACCOUNT-ID
Available Scripts
List Campaigns
python3 scripts/get_campaigns.py --account YOUR-ACCOUNT-ID
Get Account Performance Summary
python3 scripts/get_account_summary.py --account YOUR-ACCOUNT-ID --days 30
Run Custom GAQL Queries
python3 scripts/gaql_query.py --account YOUR-ACCOUNT-ID --query "SELECT campaign.id, campaign.name, metrics.impressions FROM campaign WHERE segments.date DURING LAST_30_DAYS"
Google Ads Setup Requirements
- Google Ads Account with API access enabled
- Manager Account (MCC) recommended for multiple client accounts
- OAuth Credentials in Google Cloud Console
- Developer Token from Google Ads API Center
Enabling API Access
- Go to ads.google.com
- Navigate to Tools & Settings > Setup > API Center
- Apply for API access (Basic Access required for production use)
- Note your Developer Token
Setting Up OAuth
- Go to Google Cloud Console
- Create or select a project
- Enable Google Ads API
- Go to APIs & Services > Credentials
- Create OAuth 2.0 credentials (Desktop app)
- Download the client secrets JSON
- Add the Google Ads scope:
https://www.googleapis.com/auth/adwords
GAQL Reference
See references/gaql-examples.md for common query patterns and examples.
Data Privacy
- All customer data should be scrubbed for PII before sharing
- Never commit credentials to version control
- Use environment variables or secure credential storage