Sub topic 11
Reading trends: smoothing, seasonality and year-over-year
This chapter shows how to separate a real change in search performance from weekday patterns, seasonal swings and random noise. It assumes you already have a daily table with the columns date, query, page, clicks, impressions, ctr and position, built in the earlier chapters. It also assumes you know how to compute impression-weighted average position. Basic pandas or SQL helps.
Why raw daily lines mislead
A daily clicks chart looks busy for three reasons that have nothing to do with your SEO work.
- Noise. Small counts fluctuate at random. A query with 6 clicks one day and 3 the next has not lost half its audience.
- Weekly rhythm. Many sites get more traffic on weekdays (B2B) or on weekends (recipes, entertainment). A Monday-to-Saturday drop can be normal.
- Seasonality. Demand for many topics rises and falls through the year. Tax terms peak in spring, gift terms in November and December, and holiday terms around the holidays.
A trend analysis removes or accounts for each of these, in that order: smooth the short-term noise, then compare against the same point in the previous cycle.
Smoothing with a rolling mean
A rolling mean replaces each day's value with the average of a window of days ending on that day. A 7-day window is the standard choice for search data because it contains exactly one of each weekday. That removes the weekly pattern completely, rather than only reducing it.
Prefer a window length that is a multiple of 7. A 5-day or 10-day window leaves a residual weekday effect, which shows up as a repeating ripple.
import pandas as pd
df = pd.read_csv("gsc_daily.csv", parse_dates=["date"])
daily = df.groupby("date")["clicks"].sum().asfreq("D", fill_value=0)
# 7-day rolling mean smooths the weekday pattern
trend = daily.rolling(7).mean()
# 28-day clicks compared with the same 28 days one year earlier (364 days keeps weekdays aligned)
yoy_change = daily.rolling(28).sum() / daily.shift(364).rolling(28).sum() - 1Note the asfreq("D", fill_value=0) call. If a date has no rows, groupby skips it, and the rolling window then spans more than seven calendar days. Reindexing to a complete daily calendar fixes that. Filling with 0 is correct only when a missing day truly means no clicks. If the day is missing because your collection job failed, fill with NaN instead, so the gap stays visible and does not look like a collapse.
Choosing a window
| Window | Good for | Cost |
|---|---|---|
| 7 days | Spotting a change within one to two weeks | Still noisy for low-volume queries |
| 28 days | Judging a page group or the whole site | Reacts about two weeks late to a step change |
| 90 days | Strategic direction | Hides short events such as an outage |
A rolling mean always lags. The value on day t describes the week ending at t, so a drop that began on day t − 3 is only partly visible. A centered window (rolling(7, center=True)) lines up better with the event for historical charts, but it needs future data, so do not use it for alerting or for the most recent week.
Smoothing ratio metrics correctly
Clicks and impressions are counts, so you can average or sum them. CTR and position are ratios, and they need care.
- CTR: divide summed clicks by summed impressions over the window. Do not average daily CTR values, because a day with 50 impressions would count as much as a day with 50,000.
- Position: use the impression-weighted average from the previous chapter, not the plain mean of daily positions.
import pandas as pd
df = pd.read_csv("gsc_daily.csv", parse_dates=["date"])
df["pos_x_impr"] = df["position"] * df["impressions"]
by_day = df.groupby("date")[["clicks", "impressions", "pos_x_impr"]].sum()
by_day = by_day.asfreq("D")
roll = by_day.rolling(7, min_periods=7).sum()
roll["ctr"] = roll["clicks"] / roll["impressions"]
roll["avg_position"] = roll["pos_x_impr"] / roll["impressions"]The pattern is the same each time: sum the numerators and denominators over the window first, then divide. min_periods=7 makes the first six rows NaN instead of showing a partial window that looks like a real value.
Seasonality and year-over-year comparison
Smoothing removes short cycles. It does not remove a yearly cycle. If clicks rose 40% in November, a rolling mean shows a rise, but it cannot tell you whether the rise is better than a normal November.
Year-over-year (YoY) comparison answers that question. It compares a period with the same period one year earlier, so both include the same season.
Two details matter:
- Align weekdays. Shifting by 365 days moves the comparison from a Friday to a Thursday (or a Wednesday in a leap year). Shifting by 364 days, which is 52 weeks, keeps weekdays aligned. The code above uses 364.
- Compare totals over a window, not single days. A single-day YoY ratio is mostly noise. A 28-day sum against the matching 28-day sum is stable.
Floating holidays break even a well-aligned comparison. Easter, Thanksgiving in the US, Black Friday and Lunar New Year fall on different calendar dates each year. A 28-day window that contains one holiday this year and not last year will show a misleading YoY result. When you compare periods that include a moving holiday, name it in your report.
The same calculation in SQL
-- PostgreSQL syntax; table gsc_daily(date, query, page, clicks, impressions, position)
WITH weekly AS (
SELECT
DATE_TRUNC('week', date) AS week,
SUM(clicks) AS clicks,
SUM(impressions) AS impressions,
SUM(position * impressions) / NULLIF(SUM(impressions), 0) AS avg_position
FROM gsc_daily
GROUP BY 1
)
SELECT
week,
clicks,
clicks - LAG(clicks) OVER (ORDER BY week) AS clicks_change,
avg_position
FROM weekly
ORDER BY week;This gives week-over-week change. Weekly totals remove the weekday pattern, but week-over-week still includes seasonality. To get YoY at the weekly grain, change LAG(clicks) to LAG(clicks, 52). That works only if every week is present in the table, so check for gaps first.
Edge cases that break trend comparisons
- Short history. YoY needs at least 13 months of data. Search Console keeps about 16 months, so start storing data early. Without your own stored history, the earliest comparisons disappear.
- A changed denominator. If you add 200 new keywords to a tracked set, the total clicks rise without any ranking change. Compare like with like, using a fixed query or page set, or report new and existing items separately.
- Low-volume series. When a segment gets fewer than roughly 100 clicks per week, even a 28-day YoY percentage swings widely. Report absolute numbers next to the percentage.
- Base effects. A drop of 50% followed by a rise of 50% does not return you to the start. When you compare a recovery against the prior year, remember that the prior year may itself have been depressed.
- Anomalous last year. If last year had a site outage, a migration or a core update, YoY against it is unreliable. Use an annotation (see the next chapter) or compare to a two-year-ago baseline.
- Data delays. The most recent one to three days in Search Console are often incomplete. Trim them from the right edge of any chart, or mark them as provisional. An apparent drop on the final day is usually missing data, not lost traffic.
A reading routine
Use the same order each time you open a trend chart:
- Look at the 7-day mean for the direction of the level.
- Check the YoY change over 28 days to see whether the direction is better or worse than the season suggests.
- Check whether impressions and position moved, or only CTR. A fall in clicks with steady impressions and position points at the result's appearance (title, snippet, features). A fall in impressions with a worse position points at ranking.
- Look for a known event on or just before the change date.
Summary
Smooth with windows that are multiples of 7 days. Compute ratios from summed numerators and denominators. Compare against the same weekday-aligned period a year earlier to account for season. Watch for gaps, provisional days, moving holidays and changes in what you track.
Exercise
Your 7-day rolling mean of clicks fell 12% over the last week, but the 28-day YoY change is +9%. Last year's equivalent week included Black Friday and this year's does not. What do you conclude, and what would you do next?
Show answer
The week-over-week fall is probably at least partly seasonal and holiday-related. Last year's comparison week had a moving holiday that this year's window lacks, so the weekly drop may be a calendar effect. The +9% 28-day YoY suggests the longer-term level is healthy. Next, align the comparison on the holiday (compare this year's Black Friday week with last year's), check the final days for provisional data, and confirm impressions and position are stable. Investigate only if they have also worsened.
Exercise
A colleague computes weekly CTR as the mean of seven daily CTR values. Explain why this can be wrong and give the correct calculation.
Show answer
The mean gives every day equal weight, even if one day has far fewer impressions than another, so low-volume days distort the result. The correct calculation is the sum of clicks over the week divided by the sum of impressions over the week.