← Back to Home / SEO Prompts

Google Ads Script Automation

Automate Google Ads management with scripts.

Act as a Google Ads automation specialist who has written scripts for agencies managing over $100 million in annual ad spend, automating bid management, budget pacing, keyword pruning, and reporting to save 50+ hours monthly per account. Generate a complete Google Ads script for a specific automation use case (budget pacing, bid adjustment, keyword management, performance alerting, asset testing, report generation), including main function logic, selectors, conditions, and actions. Begin with script structure including main() function required, iteration through accounts via AdsApp.accounts() or specific account ID, selector building with condition filters (date range, campaigns, ad groups, status), result set iteration with .get() and .hasNext(), error handling with try/catch blocks, logging with Logger.log(), and execution time limits monitoring (30 minutes per script, split across executions). Develop budget pacing script including daily budget calculation (monthly budget / days in month, daily spend target), actual spend retrieval (Stats for date range TODAY, getCost()), spend percentage calculation (actual spend / daily target), remaining daily budget calculation, budget adjustment logic (if spend <80% target: increase 10-20%, if spend >120% target: decrease 10-20%, if within range: no change), campaign selector (for spending campaigns, exclude experiments and drafts), schedule setup (hourly execution, 9 AM for morning check, 1 PM for midday, 6 PM for evening), and alerting on significant adjustments (email via MailApp, Slack webhook). Create keyword performance script including performance period selection (last 14 days for seasonal, last 30 days for stable), performance threshold conditions (impressions >1000, CTR <1% for above average position, CPA >target by 30%, ROAS <target by 30%, quality score <5/10), keyword selector (enabled keywords, specific campaigns, match types), action based on performance (pause for long-term underperformers, bid down for high spend low return, bid up for low spend high return, move to negative for irrelevant conversions), label application for tracking (Label = "paused_by_script_" + date, "under_review", "testing"), and exception handling (brand keywords separate, high-volume separate, manual bid strategy exclusion). Implement performance alerting script including metric thresholds (CPA > 2x target, CTR drop >30% week over week, conversion drop >40%, impression share loss >50%, cost >120% budget), account and campaign iteration with Stats for comparison periods (last 7 days vs previous 7 days, last 30 days vs previous 30 days), condition checking with percentage change calculation, alert aggregation by campaign or account level, alert delivery via email formatted HTML table, Slack webhook with @channel mention for critical alerts, Google Sheets logging for historical tracking, and alert fatigue prevention (cooldown 24 hours per alert type, threshold tuning over time). Add reporting script including report type definition (daily account snapshot, weekly campaign performance, monthly keyword analysis), report builder using AdsApp.report() with AWQL or GAQL query, result set iteration with .rows() iterator, data transformation to array of objects, Google Sheets export using SpreadsheetApp (create or open sheet, clear existing data, write headers, write rows, format columns), email delivery with PDF attachment (DriveApp PDF creation, MailApp send with HTML body), and scheduled execution via Google Apps Script triggers (daily at 8 AM, weekly Monday 6 AM, monthly 1st day 5 AM). Include advanced automation including automated ad copy testing (create new ad variation, pause worst performer after threshold, rotate evenly for 14 days, statistical significance calculation), automated negative keyword discovery (search term report analysis, irrelevant term addition to negative list, conflict avoidance with phrase negatives), automated bid management by device (mobile bid adjustment based on conversion rate, desktop vs tablet performance, time-of-day bid modifiers, location bid adjustments by ROAS), and automated asset management (sitelink validation remove broken links, callout rotation test best performers, structured snippet expiration removal, promotion extension date checking). Provide script management including version control (Script name with version number, change log in comments), error notification (try/catch with email on failure, retry logic for transient errors, execution time monitoring), approval workflow (test account execution first, parameterized thresholds, dry-run mode with logging only, gradual rollout to campaigns), and performance monitoring (execution time logs, rows processed counts, actions taken counts, alert frequency tracking).