When a stakeholder says 'traffic dropped 20% this week', the first question isn't 'why?' — it's 'compared to what?' Weekly traffic has trend, seasonal, and residual components.
Decompose with STL (Seasonal and Trend decomposition using Loess) in R or statsmodels in Python. Only the residual component represents genuine anomalies. A 20% drop that falls within the seasonal pattern is expected. A 5% residual anomaly that breaks the trend is the actual signal.
Build anomaly detection on the residual: flag observations beyond 2.5 standard deviations of the rolling residual distribution. Alert on genuine anomalies, not calendar effects. This saves analysts from the monthly ritual of explaining that traffic dips on public holidays.
The practical implementation: run STL with a weekly period on at least 52 weeks of daily traffic data. Store the components in BigQuery. Build a Looker Studio dashboard that shows the raw series, the trend, and the residual with anomaly bands. When a stakeholder asks about a traffic change, you can show instantly whether it's seasonal (expected), trend-driven (gradual shift), or residual (genuine anomaly requiring investigation).
For more sophisticated alerting, use Prophet (by Meta) or BSTS (Bayesian Structural Time Series), which model holidays, special events, and multiple seasonalities (daily + weekly + yearly) directly. These models produce prediction intervals that serve as natural anomaly thresholds.
Viktor Kvant
Senior Web Analyst specialising in data ownership, advanced tracking implementations, and translating data into strategic business value.
Connect on LinkedIn