What is Google Ads Agent?
Google Ads Agent is an internal AI-powered platform for automating Google Ads campaign management across all Color Ecommerce accounts. It combines Google Ads API integration, Claude AI analysis, and a human-in-the-loop approval workflow to continuously monitor, analyze, and optimize campaigns.
Purpose
- Reduce manual optimization time by 60%
- Improve ROAS by 15% through continuous AI analysis
- Detect performance anomalies within 1 hour
- Analyze 100% of managed accounts daily
Core Capabilities
- Continuous monitoring of all managed accounts
- AI-driven analysis identifying opportunities and risks
- Automated recommendations with reasoning and projected impact
- Full audit trail of every change proposed and executed
How It Works
Sync
Fetches account structure, metrics, and search terms via Google Ads API
Analyze
Claude AI identifies anomalies, trends, and optimization opportunities
Propose
Generates change proposals with impact projections and confidence scores
Execute
Approved changes are applied via API with full audit logging
Google Ads API Integration
Detailed breakdown of every Google Ads API service, method, and query pattern used by the application. All mutations are gated behind the human-in-the-loop approval workflow — no changes are made without explicit approval.
Account Management
| Service | Method | Purpose | Frequency |
|---|---|---|---|
| CustomerService | ListAccessibleCustomers | Discover MCC hierarchy and client accounts | On OAuth connect |
| GoogleAdsService | SearchStream | Fetch account-level settings and status | Daily sync |
Campaign Data
| Service | Method | Purpose | Frequency |
|---|---|---|---|
| GoogleAdsService | SearchStream | Query campaigns, ad groups, keywords, ads structure | Daily (6 AM) |
| GoogleAdsService | SearchStream | Fetch daily performance metrics (clicks, impressions, cost, conversions) | Hourly / Daily |
| GoogleAdsService | SearchStream | Search term report data for keyword mining | Daily (8 AM) |
Optimization Mutations
| Service | Method | Purpose | Frequency |
|---|---|---|---|
| GoogleAdsService | Mutate | Campaign budget adjustments | On approval |
| GoogleAdsService | Mutate | Keyword bid adjustments and match type changes | On approval |
| GoogleAdsService | Mutate | Add/remove negative keywords | On approval |
| GoogleAdsService | Mutate | Ad copy create/update (RSA assets) | On approval |
| GoogleAdsService | Mutate | Campaign/ad group status changes (pause/enable) | On approval |
Recommendations
| Service | Method | Purpose | Frequency |
|---|---|---|---|
| RecommendationService | SearchStream | Fetch Google's optimization recommendations | Daily (7 AM) |
| RecommendationService | ApplyRecommendation | Apply approved Google recommendations | On approval |
| RecommendationService | DismissRecommendation | Dismiss irrelevant recommendations | On approval |
Change History
| Service | Method | Purpose | Frequency |
|---|---|---|---|
| GoogleAdsService | SearchStream | Audit external changes made outside our platform | Every 12 hours |
GAQL Queries
All data is queried using Google Ads Query Language (GAQL). Below are the primary query patterns:
Campaign structure sync
SELECT campaign.id, campaign.name, campaign.status, campaign.budget FROM campaignAd group structure sync
SELECT ad_group.id, ad_group.name, ad_group.status FROM ad_groupKeyword data
SELECT ad_group_criterion.keyword.text, ad_group_criterion.keyword.match_type FROM ad_group_criterion WHERE ...Performance metrics
SELECT metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions FROM campaign WHERE segments.date DURING ...Search term mining
SELECT search_term_view.search_term, metrics.impressions, metrics.clicks, metrics.conversions FROM search_term_view WHERE ...Recommendations
SELECT recommendation.type, recommendation.impact, recommendation.campaign_budget_recommendation FROM recommendation WHERE ...External change detection
SELECT change_event.change_date_time, change_event.user_email, change_event.changed_resource FROM change_event WHERE ...Data Handling & GDPR
We take data protection seriously. All personal data is encrypted, retained only as long as necessary, and processed in compliance with GDPR and Google's API Terms of Service.
Data Inventory
| Category | Data Elements | Retention | Encryption |
|---|---|---|---|
| User Authentication | OAuth tokens, JWT sessions, IP addresses | Until revoked + 30 days | AES-256-GCM (tokens), TLS (transit) |
| User Identity | Email, display name | Account lifetime + 30 days | Database encryption at rest |
| Account Data | Customer IDs, MCC hierarchy, account names | Active lifetime + 90 days | Database encryption at rest |
| Advertising Data | Campaign names, keywords, metrics, search terms | Rolling 24 months | Database encryption at rest |
| Change History | Proposals, approvals, execution results | 36 months | Database encryption at rest |
| Operational Logs | Request IDs, IPs, user agents | 90 days | TLS in transit |
Security Measures
Encryption
- TLS 1.2+ for all data in transit
- AES-256-GCM for OAuth refresh tokens
- Database-level encryption at rest
- Redis TLS + encrypted volumes
Access Control
- Google OAuth 2.0 authentication
- JWT-based sessions (1h expiry)
- Rate limiting (100 req/min per IP)
- CORS restricted to allowed origins
Data Minimization
- Only necessary Google Ads data fetched
- User profile limited to email & name
- Logs exclude request/response bodies
- Metrics aggregated where possible
Data Subject Rights (GDPR)
Export all personal data in JSON format within 30 days of request.
Delete all records and anonymize associated logs upon verified request.
Provide data in a structured, machine-readable format for transfer.
Correct any inaccurate personal data upon notification.
Pause processing of personal data while disputes are resolved.
Opt out of non-essential data processing and analytics logging.
Cookie & Tracking Policy
This application uses only strictly necessary cookies: a JWT session token (HTTP-only, SameSite=Strict, 24h), a CSRF state token (10-minute expiry), and request ID headers for debugging. We do not use Google Analytics, advertising pixels, social media trackers, or any third-party tracking services.
System Architecture
The application is a TypeScript monorepo with four services, a shared core package, and infrastructure backed by PostgreSQL, Redis, and BullMQ.
Application Layer
API Server
Fastify + JWT Auth
Worker
BullMQ Jobs
Dashboard
Next.js 15
MCP Server
Claude Integration
Shared Packages
@core
Google Ads client, analysis, services
@shared
Types, constants, GAQL builders
@db / @queue
Drizzle ORM, BullMQ queues
Infrastructure
PostgreSQL
Accounts, metrics, proposals, audit log
Redis
Cache, rate limiting, locks
BullMQ
Job queues, scheduling
OAuth 2.0 Flow
Initiate
User clicks "Connect Google Ads" → redirected to Google consent screen
Consent
User grants access to manage Google Ads accounts
Callback
Authorization code returned to /api/auth/google/callback
Exchange
Code exchanged for access + refresh tokens. Refresh token encrypted with AES-256-GCM
Session
JWT issued (1h expiry). Refresh token stored encrypted in database
Queue Architecture
| Queue | Concurrency | Purpose | Schedule |
|---|---|---|---|
| sync | 10 | Account structure & metrics sync | Hourly / Daily 6 AM |
| analysis | 5 | AI analysis pipeline | Daily 7 AM |
| optimization | 3 | Execute approved changes | On approval |
| report | 5 | Report generation | Weekly / Monthly |
| alert | 10 | Alert notifications | On trigger |
| change-detection | 5 | Detect external changes | Every 12 hours |
Rate Limiting & Error Handling
The application is designed for responsible API usage with multiple layers of rate limiting, intelligent retry logic, and comprehensive error handling to prevent quota exhaustion.
Token Bucket Rate Limiter
A token bucket algorithm controls request flow to the Google Ads API, preventing burst traffic from exceeding quota limits.
// Rate limiting configuration
Global: 100 requests/minute per IP
Google Ads API: Token bucket per account
Concurrent accounts: Max 5 (configurable)
BullMQ rate: 10 jobs/min per queue
Exponential Backoff Retry
All API calls use exponential backoff with jitter on transient failures, with a maximum of 3 retry attempts before failing gracefully.
// Retry strategy
Attempt 1: Immediate
Attempt 2: ~2s delay (1s * 2^1)
Attempt 3: ~4s delay (1s * 2^2)
Attempt 4: Fail with structured error
Error Handling Strategy
| Error Type | Response | Retry? |
|---|---|---|
| RATE_LIMIT_EXCEEDED (429) | Back off and retry with exponential delay | Yes (up to 3x) |
| QUOTA_EXCEEDED | Log warning, skip account, retry in next cycle | Next scheduled run |
| AUTHENTICATION_ERROR | Attempt token refresh, notify if refresh fails | After refresh |
| PARTIAL_FAILURE | Log individual operation failures, continue with successes | Failed ops only |
| INTERNAL_ERROR (5xx) | Retry with backoff, alert after 3 failures | Yes (up to 3x) |
| INVALID_ARGUMENT | Log error details, skip operation, create alert | No (fix required) |
BullMQ Queue Safeguards
- Job deduplication via unique jobId per account/operation
- Configurable concurrency per queue (3-10 workers)
- Automatic retry with exponential backoff on failure
- Dead letter queue for permanently failed jobs
- Job retention limits (500 completed, 2000 failed)
Monitoring & Observability
- Prometheus-compatible metrics at /api/metrics
- Per-client rate limit tracking at /api/admin/rate-limits
- Structured error tracking with event IDs
- Transaction-level performance monitoring
- Health check endpoint at /api/health
Application Screenshots
Interactive mockups of the key dashboard screens showing account management, proposal workflow, and reporting capabilities.
Acme Corporation
123-456-7890
Widget Industries
234-567-8901
TechStart Inc
345-678-9012
Global Commerce
456-789-0123
Add negative keyword "free trial" to Campaign Alpha
Negative Keyword
Increase budget for "Brand Terms" by 15%
Budget
Pause underperforming ad group "Generic Terms"
Status Change
Total Spend
$86.9K
Conversions
2,847
Avg CPA
$30.52
Avg ROAS
4.1x
Negative Keywords
Min confidence: >85% | Zero conversions, max 20/batch
Bid Adjustments
Min confidence: >90% | Max 15% change, 30+ data points
Budget Changes
Min confidence: >95% | Max 10% increase, min 14 days data