Account Anomaly Detector - Single Account

This script is for a single account. For operating on multiple
accounts in a manager account, use the
Ads Manager
version of the script.

Account Anomaly Detector alerts the advertiser whenever a Google Ads account
is suddenly behaving too differently from what's historically observed. When an
issue is encountered, the script will send the user an alerting email. Only a
single email for an alert is sent per day.

The script is comparing stats observed so far today with historical stats for
the same day of week. For instance, stats for a Tuesday, 13:00 are compared with
stats for 26 previous Tuesdays. Adjust the number of weeks to look back
depending on the age and stability of your account.

Scheduling

Schedule the script to run Hourly in order to get the most
out of alerting. If the alert is too noisy, scheduling it Daily
around mid-day might also make sense.

How it works

Suppose the script runs at 7pm on a Tuesday. Since Google Ads statistics may be
up to 3 hours delayed,
the script will only consider stats up to 4pm.

The script will then fetch stats for 26 preceding Tuesdays, average them, and
compare with today's stats.

No subsequent alerts of the same type will be triggered for the day. If you'd
like to reset the alert, delete the Alerting cell value.