Google Ads account management involves countless repetitive tasks: checking budgets, pausing underperforming keywords, generating reports, monitoring for anomalies, and adjusting bids based on performance. For accounts of any significant size, these tasks consume hours every week, time that could be spent on strategy and creative optimization. Google Ads Scripts offer a solution by automating these routine operations with JavaScript code that runs directly within your account.

Scripts range from simple one-liners that pause ads with zero impressions to sophisticated multi-step automations that integrate external data, apply complex bidding logic, and generate comprehensive reports. The barrier to entry is lower than you might think. With pre-built scripts and basic customization, even non-programmers can implement powerful automations that transform account management efficiency.

This guide presents 21 practical script automations organized by function, from bid management to reporting to maintenance tasks. Each section includes the logic behind the automation, implementation considerations, and guidance on customization for your specific needs. Whether you're new to scripts or looking to expand your automation toolkit, these templates provide a foundation for more efficient Google Ads management.

Understanding Google Ads Scripts: The Foundation

Before diving into specific automations, understanding how Google Ads Scripts work helps you implement and customize them effectively. Scripts are JavaScript programs that run within Google's infrastructure, accessing your account data through specific APIs and making changes programmatically.

How Scripts Access Your Account

Google Ads Scripts use a simplified API that mirrors the Google Ads interface structure. You access campaigns, ad groups, keywords, and ads through selector objects that filter entities based on conditions. For example, you might select all keywords with a Quality Score below 5, or all campaigns that spent more than $100 yesterday.

  • Selectors: Filter entities by conditions (status, metrics, labels, date ranges)
  • Iterators: Loop through selected entities to read data or make changes
  • Builders: Create new entities like keywords, ads, or ad groups
  • Reporting: Pull aggregate data using GAQL (Google Ads Query Language)

The scripting environment includes utilities for common operations: sending emails via MailApp, reading and writing Google Sheets with SpreadsheetApp, fetching external URLs with UrlFetchApp, and logging for debugging. These building blocks combine to create automations that would otherwise require expensive third-party tools or custom API development.

Script Execution and Scheduling

Scripts can run manually (for testing or one-off tasks) or on automated schedules. Scheduled scripts execute at your specified frequency: hourly, daily, weekly, or monthly. The 30-minute execution limit means complex scripts processing large accounts need efficiency optimization.

Schedule TypeBest Use CasesConsiderations
HourlyBudget pacing, real-time alerts, inventory syncUse sparingly; 24 runs per day can hit API limits on large accounts
DailyPerformance reports, bid adjustments, maintenance tasksMost common frequency; run during low-traffic hours to minimize impact
WeeklySearch term mining, deep optimization, trend analysisGood for tasks that need accumulated data or don't require frequent updates
MonthlyMonthly reports, budget reconciliation, seasonal adjustmentsSchedule for first few days of month when processing previous month data

Bid Management Automations (Scripts 1-5)

While Smart Bidding handles much of modern bid optimization, scripts remain valuable for manual CPC campaigns, bid adjustments, and scenarios where you need rule-based logic that automated bidding doesn't support.

Script 1: Position-Based Bid Adjustments

This script adjusts keyword bids to maintain target average positions. While Google removed average position as a metric, you can use impression share and top impression rate as proxies for visibility targets.

  • Logic: Increase bids by X% for keywords below target top impression rate; decrease for those significantly above target
  • Safeguards: Maximum bid caps prevent runaway increases; minimum impression thresholds ensure statistical significance
  • Customization: Set different targets for brand vs. non-brand keywords; adjust change increments based on competition

Script 2: Dayparting Bid Modifiers

Automatically adjusts time-of-day and day-of-week bid modifiers based on conversion performance patterns. The script analyzes historical performance by hour and day, then applies bid adjustments to concentrate spend during high-converting periods.

  • Logic: Calculate conversion rate by hour/day; apply positive modifiers to above-average periods, negative to below-average
  • Data requirement: Needs sufficient conversion volume for statistical validity; typically 4-8 weeks of data minimum
  • Update frequency: Weekly updates capture trends while avoiding overreaction to short-term fluctuations

Script 3: Weather-Based Bid Adjustments

For businesses with weather-sensitive demand, this script fetches weather data from external APIs and adjusts bids accordingly. HVAC companies increase bids during extreme temperatures; umbrella retailers bid up when rain is forecast.

  • Integration: Uses UrlFetchApp to query weather APIs (OpenWeatherMap, Weather.gov)
  • Logic: Define bid multipliers for weather conditions; apply to campaigns targeting affected geographic areas
  • Considerations: API rate limits; caching to minimize external calls; fallback for API failures

Script 4: ROAS-Based Keyword Bid Rules

Implements tiered bid adjustments based on keyword-level ROAS performance. Keywords exceeding ROAS targets get bid increases to capture more volume; underperformers get decreases or pauses.

  • Tiers: Define ROAS thresholds (e.g., above 500% = +15% bid, 300-500% = maintain, below 300% = -10%)
  • Minimum data: Require minimum spend or conversions before applying rules to avoid statistical noise
  • Integration: Works well with manual CPC; can supplement Smart Bidding with portfolio-level insights

Script 5: Competitor-Aware Bidding

Monitors Auction Insights data and adjusts bidding aggression based on competitive dynamics. When key competitors increase impression share, the script can respond with targeted bid increases on high-value keywords.

  • Data source: Uses GAQL to pull Auction Insights metrics programmatically
  • Logic: Track competitor overlap rate and position above rate; trigger adjustments when thresholds exceeded
  • Alerts: Send notifications when significant competitive shifts detected

Budget Management Automations (Scripts 6-9)

Budget management scripts help prevent overspend, ensure even pacing, and reallocate budget to top performers. These automations are particularly valuable for agencies managing multiple client accounts or advertisers with strict monthly budgets.

Script 6: Budget Pacing Monitor

Tracks daily spend against monthly budget targets, alerting when campaigns are pacing ahead or behind schedule. Advanced versions automatically adjust daily budgets to maintain even monthly distribution.

  • Calculation: Compare actual month-to-date spend vs. expected spend at current date
  • Alerts: Email notifications when pacing deviates more than X% from target
  • Auto-adjustment: Optionally recalculate and update daily budgets to get back on pace

For comprehensive budget strategies beyond scripts, see our automated reporting guide for dashboard-based monitoring approaches.

Script 7: Overspend Prevention

Monitors account or campaign spend in real-time (hourly execution) and pauses campaigns when spend approaches budget limits. Essential for accounts with hard budget caps that cannot be exceeded.

  • Triggers: Pause campaigns when spend reaches 95% of daily or monthly budget
  • Granularity: Can operate at account, campaign, or ad group level
  • Recovery: Companion script to re-enable campaigns at start of new period

Script 8: Budget Reallocation

Automatically shifts budget from underperforming campaigns to those with capacity and strong performance. Particularly useful for accounts with many campaigns where manual reallocation is impractical.

  • Criteria: Define performance thresholds (ROAS, CPA, conversion rate) for donor and recipient campaigns
  • Limits: Set maximum percentage change per execution to prevent dramatic swings
  • Frequency: Daily execution balances responsiveness with stability

Script 9: Shared Budget Monitoring

Tracks performance of campaigns using shared budgets, identifying when budget limits constrain high-performing campaigns while low performers consume allocation.

  • Analysis: Compare lost impression share due to budget across campaigns in shared budget
  • Recommendations: Generate reports suggesting budget increases or campaign removals from shared budget
  • Alerts: Notify when top performers consistently limited by shared budget

Reporting and Analytics Automations (Scripts 10-14)

Automated reporting scripts eliminate hours of manual data pulling and formatting. They generate consistent reports on schedule, ensuring stakeholders always have current performance data. For broader automation strategies, explore our marketing automation stack guide.

Script 10: Daily Performance Digest

Sends a morning email summarizing yesterday's performance: spend, conversions, ROAS/CPA, and comparison to previous period. Provides at-a-glance account health without logging into the interface.

  • Metrics: Customizable metric selection; typically spend, conversions, revenue, CPA, ROAS
  • Comparison: Include week-over-week or month-over-month percentage changes
  • Formatting: HTML email with conditional formatting (green for improvements, red for declines)

Script 11: Search Term Report Export

Automatically exports search term reports to Google Sheets for analysis and negative keyword identification. The script can run weekly, appending new data for trend analysis over time.

  • Filtering: Export only terms with minimum impressions/clicks to focus on significant queries
  • Calculations: Add columns for estimated value (clicks times conversion rate times AOV)
  • Organization: Separate sheets by campaign or ad group for easier review

Script 12: Quality Score Tracker

Monitors keyword Quality Scores over time, tracking improvements and declines. Creates historical record that's not available in the standard interface. For optimization strategies, reference our Quality Score guide.

  • Data captured: Quality Score components (expected CTR, ad relevance, landing page experience)
  • Alerts: Notify when high-volume keywords drop below threshold
  • Trending: Calculate account-level weighted average QS over time

Script 13: Automated Client Reports

Generates formatted weekly or monthly reports and emails them to clients automatically. Includes customizable sections for different client needs and white-labeling options.

  • Format: HTML email or Google Slides/Docs attachment
  • Sections: Executive summary, campaign breakdown, top performers, recommendations
  • Scheduling: Typically weekly on Monday mornings or monthly after month close

Script 14: Conversion Lag Analysis

Analyzes conversion attribution windows to understand how long conversions take from click to completion. Helps set appropriate lookback windows and evaluate recent campaign changes accurately.

  • Analysis: Track conversions by days-since-click using ConversionLagBucket
  • Output: Charts showing conversion distribution over attribution window
  • Application: Adjust performance evaluation timing based on actual conversion lag

Alert and Monitoring Scripts (Scripts 15-18)

Proactive monitoring scripts catch problems before they significantly impact performance. These automations watch for anomalies, broken elements, and policy issues that require immediate attention.

Script 15: Anomaly Detection Alerts

Monitors key metrics for unusual variations from historical norms. Sends alerts when spend, CPA, or conversion volume deviates significantly from expected ranges.

  • Baseline: Calculate rolling averages and standard deviations from historical data
  • Thresholds: Typically 2-3 standard deviations for alerting; customizable by metric
  • Context: Include recent changes or known factors (promotions, seasonality) in alert messages

Script 16: Broken URL Detector

Checks all final URLs in your account for HTTP errors (404s, 500s, redirects to error pages). Pauses affected ads and sends notification with details for fixing.

  • Checking: Uses UrlFetchApp to verify each unique URL responds correctly
  • Actions: Can pause ads automatically or just send alerts for manual review
  • Frequency: Daily execution catches issues quickly; hourly for critical accounts

Script 17: Policy Violation Monitor

Tracks ad disapprovals and policy warnings across the account. Alerts when new disapprovals occur and provides summary reports of all current policy issues.

  • Tracking: Monitor ad approval status; detect changes from approved to disapproved
  • Details: Include policy violation reason and affected ad details in alerts
  • Trending: Track disapproval rate over time to identify systemic issues

Script 18: Impression Share Alert

Monitors lost impression share due to budget and rank, alerting when top campaigns experience significant visibility losses.

  • Thresholds: Alert when search lost IS (budget) exceeds X% on high-priority campaigns
  • Segmentation: Different thresholds for brand vs. non-brand campaigns
  • Recommendations: Include suggested budget or bid adjustments in alerts

Bulk Operations and Maintenance (Scripts 19-21)

Maintenance scripts handle tedious bulk operations that would take hours manually. These automations keep accounts clean, organized, and optimized without ongoing manual intervention.

Script 19: Search Term to Negative Keyword Pipeline

Analyzes search term reports and automatically adds poor-performing queries as negative keywords. Can also identify high-performing terms to add as exact match keywords.

  • Negative criteria: High impressions + low CTR, or clicks with no conversions above threshold
  • Positive criteria: Converting terms not already in account as keywords
  • Safety: Review queue option instead of automatic addition; prevent blocking valuable terms

Script 20: Ad Testing Rotation

Manages ad testing by pausing statistically inferior ads and enabling new variations. Ensures continuous testing without manual monitoring of every ad group.

  • Statistical testing: Uses confidence intervals to determine winner; typically 95% confidence
  • Minimum data: Require minimum impressions/clicks before declaring winners
  • Rotation: Can automatically create new test variants from templates

Script 21: Account Cleanup Automation

Identifies and handles inactive elements: keywords with zero impressions for 90 days, ad groups without active ads, campaigns with no recent activity. Keeps accounts lean and manageable.

  • Identification: Find keywords, ads, and ad groups with no activity in specified period
  • Actions: Pause or label for review; generate cleanup report
  • Preservation: Exclude seasonal campaigns or intentionally paused elements from cleanup

Implementing Scripts: Best Practices

Successful script implementation requires more than just copying code. Following best practices ensures scripts run reliably, make appropriate changes, and integrate smoothly with your workflow.

Testing and Validation

  • Preview mode: Always test scripts in preview mode first; see changes without applying them
  • Test accounts: For significant scripts, test in a dedicated test account before production
  • Incremental rollout: Start with one campaign or ad group before account-wide deployment
  • Logging: Add comprehensive Logger.log() statements to understand execution flow

Safeguards and Limits

  • Maximum changes: Limit the number of modifications per execution to prevent runaway changes
  • Threshold validation: Verify calculated values are within reasonable ranges before applying
  • Confirmation emails: Send summaries of all changes made for audit and reversal if needed
  • Dry run option: Build in flags to run analysis without making changes

Performance Optimization

Large accounts can hit the 30-minute execution limit. Optimize scripts to process efficiently and complete within time constraints.

  • Efficient selectors: Filter at the selector level rather than in JavaScript loops
  • Batch operations: Use batch methods where available instead of individual updates
  • Incremental processing: For very large datasets, process subsets across multiple scheduled runs
  • Caching: Store frequently accessed data (like spreadsheet values) in variables rather than repeated lookups

Integrating Scripts with External Tools

Scripts become even more powerful when integrated with external data sources and tools. The UrlFetchApp function enables connections to CRMs, inventory systems, weather services, and custom applications. For comprehensive tool integration strategies, see our Google Ads API and tools integration guide.

Google Sheets Integration

Google Sheets serves as the most common external data source for scripts. Use sheets to input configuration values, bid rules, negative keyword lists, and budget targets. Output performance data, change logs, and reports to sheets for analysis and sharing.

  • Input: Pull bid multipliers, target values, or exclusion lists from designated sheets
  • Output: Write performance data, change logs, and alerts to sheets for record-keeping
  • Formatting: Use conditional formatting in sheets to highlight issues requiring attention

External API Connections

Connect to external APIs for real-time data that influences bidding and campaign management decisions.

  • Inventory APIs: Adjust bids or pause ads for out-of-stock products
  • CRM/sales data: Import offline conversion values for better optimization
  • Weather services: Implement weather-triggered bid adjustments
  • Custom webhooks: Trigger external workflows when script conditions are met

Common Script Errors and Solutions

Understanding common script failures helps you debug issues quickly and build more robust automations.

Error TypeCommon CauseSolution
Execution timeoutProcessing too many entities; inefficient loopsOptimize selectors; process in batches; use incremental approach
Operation limit exceededMore than 250,000 operations in single runSplit processing across multiple scripts or scheduled runs
Cannot read property of undefinedAccessing data that doesn't exist; empty selectorsAdd null checks; verify selectors return results before processing
UrlFetchApp timeoutExternal service slow or unavailableAdd try-catch blocks; implement retry logic; use timeouts
Spreadsheet not foundIncorrect spreadsheet ID; permission issuesVerify ID from URL; ensure script has access to sheet
Invalid bid amountCalculated bid outside acceptable rangeAdd min/max validation before applying bid changes

Building Your Script Library

Start with proven scripts for your highest-impact needs, then expand as you gain comfort with the scripting environment. A well-curated script library becomes a significant competitive advantage, enabling management efficiency that manual processes cannot match.

Recommended Starting Point

  1. Budget pacing monitor: Essential for any account with budget targets
  2. Daily performance email: Low risk, high utility for staying informed
  3. Broken URL detector: Catches issues that silently waste budget
  4. Anomaly detection: Early warning system for performance problems
  5. Search term analysis: Ongoing optimization fuel for keyword strategy

As you become comfortable with these foundational scripts, expand into bid management automations and more complex integrations. The investment in learning Google Ads Scripts pays dividends across every account you manage, compounding efficiency gains over time.

Continue to our Google Ads API and tools integration guide for enterprise-level automation options beyond scripts. For automated reporting beyond Google Ads, explore our comprehensive automated reporting guide covering cross-platform dashboard solutions.