TwoSquaresTwoSquares
ContactFree Audit
ENBG
  1. Home
  2. Scripts
  3. Account Anomaly Detector
Back to scripts

Account Anomaly Detector

Compares today’s account performance against the same weekday across previous weeks and alerts when impressions, clicks, conversions, or cost move outside expected bounds.

alertsmonitoringaccount-healthgoogle-sheets

Script Details

Name
Account Anomaly Detector
Author
Kiril Ivanov
Updated
2026-03-19

Script Code

Use this when you want a lightweight account-health alerting script based on simple historical baselines rather than a full BI setup.

Preview is public. Unlock full code with name and email.

/**
 * ==========================================================
 * Account Anomaly Detector
 * ==========================================================
 * Description: Compares today's cumulative account stats to
 * historical weekday averages and alerts on anomalies.
 *
 * Copyright (c) 2026 TwoSquares. All Rights Reserved.
 * Developed by Kiril Ivanov
 */
const CONFIG = {
  spreadsheet_url: "YOUR_SPREADSHEET_URL",
  reporting_options: { apiVersion: "v22" }
};
// ... preview shortened
}

About This Script

Account Anomaly Detector is a monitoring script that compares today’s performance against the same weekday across prior weeks to identify unusual drops or spikes. It is useful for surfacing tracking outages, budget issues, feed problems, policy disruption, or unexpected spend behaviour early in the day.

This version is updated from older Google examples to use a current report API version and more consistent metrics handling. It still relies on a spreadsheet-driven configuration model so non-technical users can control thresholds and recipients without editing code frequently.

The logic is intentionally simple: if today’s cumulative stats up to the current hour diverge materially from the historical weekday average, the script records the anomaly and optionally emails a warning. It is not a forecasting system, but it is a practical early-warning layer.

Implementation Notes

  1. Create a copy of your monitoring spreadsheet template and replace YOUR_SPREADSHEET_URL.
  2. Set threshold cells for impressions, clicks, conversions, cost, number of weeks, and alert email.
  3. Run the script manually once to validate named ranges and spreadsheet permissions.
  4. Review output for a few days before trusting alerts operationally.
  5. Schedule it hourly or at a cadence that matches your account monitoring routine.

More Scripts In This Library

Next Script

Ad Group CPA Outlier Watchlist

Campaign Underspending Alert

Flags campaigns and shared budgets that are underspending against expected budget pace, with support for yesterday or intraday checks.

Broken Final URL Checker

Checks enabled ad and keyword final URLs for 4xx/5xx errors, with optional sheet logging and daily alerting.

Campaign Budget Limited Monitor

Surfaces enabled Search campaigns losing impression share due to budget, with optional sheet output and alerting.

Campaign Name Export

Exports all campaigns with status and channel type into a Google Sheet for quick account documentation and review.

Account Anomaly Detector FAQs

Common setup, usage, and troubleshooting questions for this script.

Dominate your market. Own your growth.

Let's build measurable growth together.

Get Free Audit
TwoSquares

Full-service digital growth agency. SEO, PPC, paid social, GEO and web development for UK brands ready to scale.

ENBG

Ask AI about TwoSquares

ChatGPT
Perplexity
Grok
Claude
Gemini

Services

  • SEO
  • GEO
  • PPC
  • Paid Social
  • Email Marketing
  • Web Design & Dev
  • CRO
  • Strategy & Planning
  • Consultancy
  • Custom Solutions

Solutions

  • AI Search Growth System
  • Demand Generation & Lifecycle
  • Pay-Monthly Websites

Audits

  • PPC Audit
  • SEO Audit
  • GEO Audit
  • Website Audit
  • Full Marketing Audit
Featured on Best in Britain

Company

  • About Us
  • Our Brands
  • Blog
  • Contact
  • Case Studies
  • Careers
  • Templates

Resources

  • Resources Hub
  • AI Readiness Toolkit
  • SEO Glossary
  • Free Tools

Industries

  • Hotels & Resorts
  • Property & Rentals
  • Restaurants & Bars
  • E‑commerce & DTC

Connect

[email protected]
SSL Secured
GDPR Compliant

© 2026 TwoSquares Limited (SC877356). All rights reserved.

Privacy PolicyTerms of ServiceCookie PolicySitemap

TWOSQUARES