1Introduction to Google Ads Scripts
Google Ads Scripts let you automate account management tasks using JavaScript. No engineering degree required—most useful scripts are simple and can be copied and customized.
What Scripts Can Do
Reporting:
- Automated performance reports
- Custom dashboards
- Scheduled email reports
- Data exports to Google Sheets
Monitoring:
- Broken link alerts
- Budget pacing alerts
- Performance anomaly detection
- Conversion tracking verification
Optimization:
- Automated bid adjustments
- Keyword management
- Negative keyword additions
- Ad scheduling updates
Bulk Operations:
- Mass updates across accounts
- Label management
- Campaign/ad group changes
- URL updates
Why Use Scripts
Time savings:
- Automate tasks you do weekly/daily
- Run reports while you sleep
- Catch issues immediately
Consistency:
- Same logic applied every time
- No human error in repetitive tasks
- Documented automation
Scale:
- Manage more accounts
- Handle complexity
- Free up strategic time
Getting Started
Access scripts:
- Sign into Google Ads
- Tools & Settings > Bulk Actions > Scripts
- Click the + button to create new
No coding background?
- Most scripts can be copied and pasted
- Customize variables only
- Start with simple scripts
2Reporting Automation Scripts
Automate your reporting with these script templates.
Daily Performance Email Script
This script sends daily performance summary via email.
What it does:
- Runs daily at your scheduled time
- Compares yesterday to previous period
- Emails key metrics summary
Setup:
- Create new script
- Paste the script code
- Set your email address
- Schedule to run daily
Key metrics included:
- Spend
- Clicks
- Conversions
- Cost per conversion
- ROAS
- Comparison to prior period
Customization points:
- Email recipients
- Metrics to include
- Comparison period
- Date range
Google Sheets Report Script
Automatically populate a Google Sheet with performance data.
What it does:
- Pulls data from your account
- Writes to specified Google Sheet
- Updates on schedule
Use cases:
- Custom dashboards
- Client reporting
- Historical data tracking
- Multi-account consolidation
Setup:
- Create Google Sheet
- Get Sheet URL and tab name
- Configure script with your parameters
- Authorize and schedule
Campaign Performance Report
Detailed campaign-level data export.
Columns included:
- Campaign name
- Status
- Budget
- Spend (configurable period)
- Impressions
- Clicks
- CTR
- Conversions
- Conversion rate
- Cost per conversion
- Conversion value
- ROAS
Report customization:
- Add/remove columns
- Filter by campaign type
- Set date ranges
- Include/exclude paused campaigns
3Alert and Monitoring Scripts
Catch problems before they become expensive.
Budget Pacing Alert
Get notified when campaigns are under or overspending.
What it monitors:
- Actual spend vs. expected spend
- Daily pacing against monthly budget
- Budget nearly exhausted warnings
Alert triggers:
- Spend below 80% of expected
- Spend above 120% of expected
- Budget will exhaust before month end
- Campaign ran out of budget
How to use:
- Set your alert threshold (e.g., 20% variance)
- Configure email recipients
- Schedule to run daily or hourly
Broken URL Alert
Detect when landing pages are broken.
What it checks:
- Final URL status codes
- 404 errors
- Server errors (500)
- Redirect issues
When it runs:
- Daily recommended
- Hourly during peak periods (optional)
Why it matters:
- Broken pages = wasted spend
- Catch issues before they cost money
- Maintain Quality Score
Conversion Tracking Alert
Detect when conversions drop unexpectedly.
What it monitors:
- Conversion count vs. historical average
- Sudden drops (e.g., 50%+ decrease)
- Zero conversions for extended period
Alert logic:
- Compare today to same day last week
- Compare to rolling average
- Flag significant deviations
Common catches:
- Tracking pixel removed/broken
- Website changes affecting conversion
- Promotional period ending
Performance Anomaly Alert
Catch unusual performance changes.
Metrics monitored:
- CTR drops
- CPC spikes
- Conversion rate changes
- ROAS fluctuations
Alert thresholds (customizable):
- CTR down 30%+
- CPC up 50%+
- CVR down 40%+
- ROAS down 30%+
Comparison period:
- Yesterday vs. prior 7-day average
- This week vs. prior 4 weeks
- Customizable
Want to see how your account stacks up?
Get a complete Google Ads audit in under 3 minutes.
4Optimization Scripts
Automate optimization tasks that you do repeatedly.
Automatic Negative Keywords
Add negative keywords based on search term performance.
Logic:
- Pull search terms with X+ clicks and 0 conversions
- Pull search terms below CVR threshold
- Add as exact match negatives
Parameters to set:
- Minimum clicks before action
- CVR threshold
- Date range to analyze
- Campaigns to include/exclude
Safety features:
- Review mode (shows what would be added)
- Apply mode (actually adds negatives)
- Log of all additions
Bid Adjustments by Time
Adjust bids based on time-of-day performance.
What it does:
- Analyzes performance by hour
- Calculates optimal bid modifiers
- Applies adjustments
Logic example:
- High CVR hours: Increase bids
- Low CVR hours: Decrease bids
- Based on your data, not assumptions
Settings:
- Minimum data threshold
- Max adjustment percentage
- Smoothing factor
- Campaigns to include
Ad Pause/Enable by Schedule
Run different ads at different times.
Use cases:
- Lunch specials (pause at 2pm)
- Weekend promotions
- Holiday messaging
- Time-zone management
How it works:
- Check current time/day
- Enable or pause ads with specific labels
- Run hourly to catch transitions
Low Quality Score Alert and Pause
Monitor and manage Quality Score.
What it does:
- Scans all keywords for QS
- Flags keywords below threshold
- Optionally pauses problem keywords
Actions:
- Alert only (for review)
- Pause and alert
- Log for later review
Thresholds:
- QS below 3: High priority
- QS below 5: Medium priority
- Monitor changes over time
5Implementing Your First Script
Step-by-step guide to getting your first script running.
Step 1: Access Scripts
- Sign into Google Ads
- Click Tools & Settings (wrench icon)
- Under "Bulk Actions," click "Scripts"
- Click the blue "+" to create new script
Step 2: Create a New Script
- Give your script a name (descriptive)
- You'll see the script editor
- This is where code goes
Step 3: Paste Script Code
Important: Delete the default "function main()" before pasting.
- Copy full script code
- Paste into editor
- Replace any placeholder values
Step 4: Customize Variables
Most scripts have a configuration section at the top:
// CONFIGURATION - Edit these values
var EMAIL_ADDRESS = "your@email.com";
var THRESHOLD = 0.20; // 20%
var DATE_RANGE = "LAST_7_DAYS";
Update these to match your needs.
Step 5: Authorize
- Click "Preview" or "Run"
- You'll see an authorization dialog
- Click "Authorize"
- Sign in with your Google account
- Grant permissions
Step 6: Preview First
Always preview before running:
- Click "Preview"
- Review the log output
- Check for errors
- Verify logic is correct
Step 7: Schedule
- Once tested, click "Save"
- Go back to Scripts list
- Click the pencil icon to edit schedule
- Set frequency (hourly, daily, weekly, monthly)
- Set specific time if relevant
- Enable the schedule
Step 8: Monitor
- Check email alerts (if configured)
- Review logs periodically
- Verify outputs (sheets, actions)
- Adjust as needed
6Troubleshooting Scripts
Common issues and how to fix them.
Error: Unauthorized
Cause: Script needs re-authorization
Fix:
- Open the script
- Click "Preview"
- Re-authorize when prompted
Why it happens:
- Password change
- Account permission changes
- Extended period of inactivity
Error: Exceeded Execution Time
Cause: Script takes too long (30-minute limit)
Fix:
- Process fewer entities at once
- Add filters to reduce scope
- Split into multiple scripts
- Use batch processing
Example fix: Instead of processing all campaigns, process by label groups.
Error: Quota Exceeded
Cause: Too many API calls
Fix:
- Add delays between operations
- Batch operations together
- Reduce frequency of runs
- Process subsets
Error: Sheet Not Found
Cause: Google Sheet URL or tab name incorrect
Fix:
- Verify Sheet URL is correct
- Check tab name matches exactly (case-sensitive)
- Ensure Sheet is shared with script account
- Re-authorize if needed
Error: Invalid Date Range
Cause: Date format issues
Fix:
- Use Google Ads date formats:
- "TODAY"
- "YESTERDAY"
- "LAST_7_DAYS"
- "LAST_30_DAYS"
- "THIS_MONTH"
- "LAST_MONTH"
Script Runs But Nothing Happens
Possible causes:
- Filters too restrictive
- No entities match criteria
- Action is in "preview" mode
- Logic error in conditions
Debug steps:
- Add Logger.log() statements
- Check for empty results
- Loosen filters to test
- Verify variable values
Email Not Sending
Possible causes:
- Email quota exceeded
- Email address incorrect
- Email content empty
Fix:
- Check daily email quota (limited per account)
- Verify email address spelling
- Ensure report has data
Want to see how your account stacks up?
Get a complete Google Ads audit in under 3 minutes.
7Script Best Practices
Follow these practices for reliable automation.
1. Always Preview First
Before running or scheduling:
- Click "Preview"
- Review all log output
- Verify expected behavior
- Check for errors
Never trust a script without testing.
2. Start Conservative
When automating:
- Set tight thresholds initially
- Use alert-only mode first
- Review before auto-applying
- Expand scope gradually
Example: First run: Alert when CVR drops 50% After tuning: Alert at 30% After trust: Auto-pause at 50% drop
3. Add Logging
Good logging:
- Records what the script did
- Shows values used in decisions
- Helps debug issues
- Provides audit trail
Add Logger.log() statements at key points.
4. Handle Errors Gracefully
Use try-catch:
- Catch errors instead of crashing
- Log the error
- Continue with other items
- Send alert if critical
5. Document Your Scripts
Include comments:
- What the script does
- Configuration options
- Date created/modified
- Author
Future you will thank you.
6. Version Control
Track changes:
- Keep copies before editing
- Note what was changed
- Maintain changelog
- Store in external location (Drive, GitHub)
7. Monitor Regularly
Check scripts periodically:
- Are they still running?
- Are outputs expected?
- Any new errors in logs?
- Performance still relevant?
8. Clean Up Old Scripts
Review periodically:
- Pause scripts no longer needed
- Archive old versions
- Remove test scripts
- Keep list organized
8Script Resources
Where to find scripts and learn more.
Official Resources
Google Ads Scripts Documentation:
- developers.google.com/google-ads/scripts
- Reference documentation
- Code samples
- Best practices
Google Ads Scripts Forum:
- Community support
- Script sharing
- Troubleshooting help
Free Script Libraries
Google's Script Library:
- Pre-built scripts from Google
- Covers common use cases
- Good starting points
Third-Party Libraries:
- Numerous blogs share free scripts
- Search for specific use cases
- Always test before trusting
Paid Script Solutions
When to consider:
- Complex requirements
- Multi-account management
- Enterprise features
- Dedicated support
Options:
- Script development agencies
- SaaS script platforms
- Freelance developers
Learning JavaScript Basics
If you want to customize:
- Codecademy (free intro)
- JavaScript basics courses
- Google's JavaScript tutorial
- Practice with simple modifications
Key concepts to learn:
- Variables
- Functions
- Loops
- Conditionals
- Arrays and objects
Building Your Script Library
Recommended starter scripts:
- Budget pacing alert
- Broken URL checker
- Performance anomaly alert
- Daily report to email
- Search term mining
As you advance:
- Bid adjustments by day/hour
- Negative keyword automation
- Quality Score monitoring
- Custom dashboards
- Multi-account reporting