Sub topic 15
Setting Alerts That Catch Real Problems
This chapter assumes you already have a daily table of Search Console data that you own, an impression-weighted position calculation, and a dashboard with weekday-aware trends. Basic Python with pandas is enough for the code. The goal is to turn that table into a small set of alert rules that fire when something needs a human, and stay quiet otherwise.
What an alert is for
A dashboard is something you look at. An alert is something that interrupts you. Interrupting is expensive, so each alert should meet three conditions:
- It points to a problem you could act on, such as a deindexed section, a broken template, a robots.txt mistake, or a stalled data pipeline.
- It fires rarely enough that people still read it after a month.
- It tells the reader where to look first.
If an alert has fired ten times and nobody did anything, remove it or change it. Ignored alerts teach the team to ignore the next one, including the real one.
Choose what to watch
Alert on a few signals that map to failures you have seen or can imagine. Alert on segments as well as the site total, because a 60% drop in one section can disappear inside a stable total.
| Signal | Level | Typical rule | Failure it catches |
|---|---|---|---|
| Clicks | Site total and each major page group | Sustained drop below a weekday baseline | Template bugs, deindexing, lost rankings |
| Impressions | Non-brand queries | Sustained drop below baseline | Lost visibility before clicks fall |
| Weighted average position | Non-brand, per segment | Worse by a set margin over a week | Ranking loss in a tracked group |
| Organic sessions vs. search clicks | Site total | Ratio leaves its normal range | Broken analytics tag, redirects, consent changes |
| Data freshness | Pipeline | Newest date older than allowed | Failed job, expired credentials |
Do not alert on single keywords unless the keyword is business-critical. Individual queries are noisy, and a long list of keyword alerts will produce constant false alarms.
Why naive thresholds fail
A rule like "alert if clicks drop 20% from yesterday" fails for four reasons.
- Weekday pattern. Many sites get fewer clicks on weekends. Comparing Monday with Sunday fires every week.
- Noise at low volume. A page group with 10 clicks a day can move 30% by chance. The smaller the count, the wider the normal swing.
- Data lag. The most recent days in Search Console are still being finalized and can look low. Alerting on them produces false drops that fix themselves.
- One-day blips. A single bad day is often a holiday, an outage, or a reporting quirk. Real problems usually persist.
The fix is to compare each day with a baseline from the same weekday, ignore low-volume segments, skip the unsettled days, and require the drop to last several days.
Build the rule: baseline, threshold, persistence
The baseline for a date is the median of the same weekday over the previous eight weeks. The median resists past outliers better than the mean. A drop is a breach when the day falls more than a set fraction below the baseline and the baseline is above a volume floor. An alert needs several consecutive breaches.
This script generates synthetic data with a weekend dip and a real 45% drop in the last five days, so you can run it as shown. Replace the generated series with your own daily clicks.
import numpy as np
import pandas as pd
def weekday_baseline(daily: pd.Series, weeks: int = 8) -> pd.Series:
"""Median of the same weekday over the previous `weeks` weeks."""
lags = pd.concat([daily.shift(7 * k) for k in range(1, weeks + 1)], axis=1)
return lags.median(axis=1)
def sustained_drops(
daily: pd.Series,
threshold: float = 0.30,
min_baseline: float = 50,
run_length: int = 3,
) -> pd.DataFrame:
baseline = weekday_baseline(daily)
change = daily / baseline - 1
breach = (change < -threshold) & (baseline >= min_baseline)
sustained = breach.astype(int).rolling(run_length).sum() == run_length
return pd.DataFrame(
{"clicks": daily, "baseline": baseline, "change": change, "alert": sustained}
)
# Synthetic example: 120 days, weekend dip, 45% drop in the last 5 days
rng = np.random.default_rng(7)
dates = pd.date_range("2026-01-01", periods=120, freq="D")
expected = np.where(dates.dayofweek >= 5, 120.0, 200.0)
expected[-5:] *= 0.55
daily = pd.Series(rng.poisson(expected), index=dates, name="clicks")
result = sustained_drops(daily)
print(result[result["alert"]].round(2))Each setting trades speed against false alarms.
thresholdsets how big a drop must be. Lower values catch smaller problems and fire more often.run_lengthsets how many days the drop must last. Higher values suppress blips but delay detection by that many days.min_baselinekeeps small segments from alerting on noise. Pick it so that a normal day-to-day swing is well under your threshold. For Poisson-like counts, the relative standard deviation is about one divided by the square root of the count, so 50 clicks gives roughly 14%.
The same function works on impressions. For position, work with weekly weighted averages and alert when a segment gets worse by a fixed number of positions, because position is already a ratio and does not need the volume-based baseline in the same way.
Alert on the pipeline too
If your collection job fails, the table stops growing. A rule built on missing data may then stay silent, or treat missing days as zeros and fire a false "traffic collapsed" alert. Check freshness before you check performance, and skip the performance rules when the data is stale.
import pandas as pd
def data_is_fresh(daily: pd.Series, today: pd.Timestamp, max_lag_days: int = 4) -> bool:
"""True if the newest row is recent enough to trust the other alerts."""
lag = (today.normalize() - daily.index.max()).days
return lag <= max_lag_days
daily = pd.Series(
[100, 110, 95],
index=pd.to_datetime(["2026-11-20", "2026-11-21", "2026-11-22"]),
)
print(data_is_fresh(daily, pd.Timestamp("2026-11-27")))This prints False: the newest row is five days old, which is over the four-day limit. In a real job, a stale result should send a pipeline alert to whoever owns the job and exit before the performance rules run.
Route by severity
Not every alert needs the same response. Define two or three levels and say in advance who receives each.
- Page now. Site-wide clicks sustained far below baseline, or the whole non-brand segment gone. This is a message to the on-call person.
- Look today. One page group or country drops, or the organic sessions to clicks ratio moves. This goes to a team channel.
- Review weekly. Position drifts, small segment changes, or new queries losing impressions. These go into the weekly report and do not interrupt anyone.
Each message should include the segment, the observed value, the baseline, the size of the change, how many days it has lasted, and a link to the dashboard view filtered to that segment. Also include recent annotations. If a deploy or migration was logged two days ago, the reader should see it immediately.
Tune with a backtest
Before you turn an alert on, run it over your full history and count how often it would have fired.
- List the real incidents you know about, such as a bad release or a ranking loss.
- Run the rule across all history and list every date it fires.
- Check that known incidents were caught, and how many days after they began.
- Look at the other firings. Mark each as explained (a holiday, a real change nobody noticed) or false.
- Adjust threshold, run length, or volume floor, and repeat.
A useful target is that nearly every firing leads to someone looking at something specific. Retest each quarter, because traffic levels and seasonality change, and a rule tuned for a small site misbehaves after the site grows.
The alert flow
Common mistakes
- Alerting on every keyword, then ignoring all of them.
- Comparing with yesterday instead of with the same weekday.
- Treating missing data as zero.
- Skipping the persistence check, which turns every outage or holiday into an alert.
- Sending alerts with no context, so the reader must rebuild the investigation from scratch.
- Never reviewing which alerts led to action.
Exercise
A page group averages 30 clicks per day. Your rule fires when clicks fall more than 30% below the weekday baseline, with no volume floor. Why will this rule misbehave, and what two changes would you make?
Show answer
At 30 clicks the normal random swing is roughly 18% (about one over the square root of 30), so a 30% drop happens by chance fairly often and the rule will fire on noise. Add a volume floor (for example, skip segments whose baseline is under 50 clicks, or merge small groups into a larger one) and require the drop to persist for several consecutive days. You could also raise the threshold for small segments.
Exercise
Your collection job failed four days ago, and your alert script builds the daily series with missing dates filled with zero. What does the alert report, and how should the script change?
Show answer
It sees four days of zero clicks, which falls far below the baseline and sustains for several days, so it reports a severe traffic collapse that did not happen. The script should check data freshness first and send a pipeline alert instead, and it should leave missing dates as missing values instead of filling them with zero.