Account Anomaly Detector
Monitors your account for unexpected performance deviations by comparing today's stats against historical averages for the same weekday. Sends an alert email when impressions, clicks, conversions, or cost deviate beyond configurable thresholds.
by Google (original), chiliad (adaptation)·developers.google.com/google-ads/scripts/docs/solutions/account-anomaly-detector
Overview
Account Anomaly Detector compares today's account performance, up to the current hour, against the average of the same weekday over the past few weeks. When impressions, clicks, or conversions fall below your thresholds — or cost rises above yours — it logs the anomaly and (if an email is set) sends an alert. Self-contained: no companion spreadsheet needed.
Setup
- 1Create a new script and paste the code.
- 2Set the low-traffic thresholds (e.g. IMPRESSIONS_THRESHOLD = 0.5 alerts when impressions are below 50% of the weekday average).
- 3Set COST_THRESHOLD for overspend (e.g. 2.0 alerts when cost exceeds 200% of the weekday average).
- 4Set WEEKS to how many past same-weekday weeks form the baseline (default 4).
- 5To receive email alerts, set EMAIL_ADDRESS; leave blank to log only.
- 6Schedule once daily (e.g. early afternoon) — running hourly re-alerts every hour the anomaly persists, since there is no cross-run de-duplication.
Configuration Variables
| Variable | Default |
|---|---|
IMPRESSIONS_THRESHOLD | 0.5 |
CLICKS_THRESHOLD | 0.5 |
CONVERSIONS_THRESHOLD | 0.5 |
COST_THRESHOLD | 2.0 |
Expected Output
=== Account Anomaly Detector (MONDAY, up to 14:00) === Clicks low: 312.0 by 14:00, expected >= 540.0 Cost high: 1240.50 USD by 14:00, expected <= 980.00 Alert emailed to you@example.com
Notes
Self-contained — no companion spreadsheet required (the original Google template needed one). It compares only the hours of the day that have elapsed against the same hours on the same weekday in prior weeks. Schedule daily rather than hourly to avoid repeat alerts.