Diagnosing Recurring and One-Off Traffic Anomalies in an E-Commerce Platform
Statistics & ExperimentsModel answerLast updated
Given three years of weekly session data with consistent autumn spikes and a single summer anomaly, identify plausible causes and validate hypotheses through segmentation and decomposition.
Scenario
You are given a three-year weekly time-series of shopping sessions on a large e-commerce platform. Two patterns stand out:
- Recurring spikes every autumn — traffic rises sharply at roughly the same time each year.
- A single isolated spike in the summer of Year 3 — it does not appear in Years 1 or 2 and has not recurred since.
What you are asked to do
Part 1 — Business reasoning
Propose plausible real-world explanations for each pattern. Separate the recurring seasonal effect from the one-off anomaly. For each explanation, state what evidence would confirm it and what would rule it out.
Part 2 — Data exploration
Using a dataset of your choice of tool (Python, R, or a spreadsheet), go beyond eyeballing the chart. Describe or implement the steps you would take to:
- Quantify each spike against an appropriate baseline.
- Check whether the spike reflects genuine demand or a measurement problem.
- Identify which segment (geography, channel, device, merchant concentration) accounts for the excess sessions.
- State at least two falsifiable hypotheses and the data you would need to test each one.
You are expected to walk through your reasoning, show code or pseudocode for the key steps, and explain how you would interpret the results.
Hints
Hint 1
Before explaining a spike, ask whether it is real. Check conversion rate, session duration, and bounce rate during the anomalous weeks — bot traffic and tracking bugs inflate sessions while leaving conversion flat or worse.
Hint 2
For the recurring autumn pattern, express each year's peak as a ratio to its own pre-spike baseline rather than comparing raw heights. That separates genuine seasonal demand from a growing platform baseline.
Hint 3
For the one-off summer spike, segment by merchant concentration first. If a handful of merchants account for most of the excess, the cause is likely a viral product or a single large campaign rather than a platform-wide event.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
What a strong answer covers
A good response does three things well: it separates a predictable seasonal pattern from a one-off anomaly (because each needs a different explanation and a different test), it checks data quality before theorizing, and it turns every explanation into a hypothesis that can be falsified with specific data.
Part 1: Plausible business drivers
Recurring autumn spikes (seasonal, expected)
1. Major shopping holidays. The largest commerce weekend of the year — combining a late-autumn discount day with its online counterpart the following Monday — falls in this window annually. Merchants run their deepest promotions, and many start "early" campaigns in the weeks before.
2. Regional equivalents. A mid-November online shopping holiday with roots in East Asia is significant for merchants with Asian audiences or cross-border logistics.
3. Gift-season lead-up. Consumers start buying holiday gifts earlier each year to beat shipping deadlines, so traffic rises steadily through autumn rather than spiking on a single day.
4. Paid media concentration. Email, SMS, and paid social budgets peak in this period. Even though ad auction prices are high, merchants spend aggressively, pulling in traffic that would otherwise not arrive.
5. Platform growth compounding the effect. If the merchant base grows 20–30% year-over-year, each autumn sits on a higher baseline. Always compare the relative spike size — peak divided by the prior four-week average — not the raw session count.
One subtlety with weekly aggregation: the late-autumn shopping weekend can land in different calendar weeks across years, and the following online shopping day sometimes falls in the next week entirely. The spike may therefore appear "spread" or slightly shifted, which is normal and not a sign of a different cause.
One-off summer spike in Year 3 (anomaly)
1. A rival platform's membership sale event held in summer can drive counter-promotions: independent merchants run competing discounts to capture demand from shoppers already in a buying mindset.
2. A viral product or merchant launch. A single large merchant — a celebrity brand, a limited-edition drop, or a product that spread on short-form video — can move platform-wide totals on its own.
3. A platform feature or new market launch. Activating a new sales channel, a native checkout promotion, or entering a large geography all concentrate new-user sessions in a single week.
4. Macro or external event. Government stimulus payments, pandemic-related demand shifts, or a major sporting event with merchandise demand can produce a one-time step.
5. Measurement artifact — rule this out first. A bot or scraper wave, a tracking tag firing twice, a session-definition change, or a data backfill can all produce a spike that looks real on a chart. These are common enough that they deserve the first look, not the last.
Part 2: Data exploration
Assume a weekly aggregated table with at least: week, sessions, orders, country, channel, device, merchant_id, is_new_visitor.
Step 1 — Quantify spikes against a baseline
Use a robust seasonal decomposition to isolate the residual component, then flag weeks whose residual is more than 3 standard deviations from the mean.
import pandas as pd
from statsmodels.tsa.seasonal import STL
df = pd.read_csv("sessions.csv", parse_dates=["date"])
df["week"] = df["date"].dt.to_period("W").dt.start_time
weekly = df.groupby("week").agg(
sessions=("sessions", "sum"),
orders=("orders", "sum")
)
# STL with robust=True down-weights outliers during fitting
stl = STL(weekly["sessions"], period=52, robust=True).fit()
weekly["resid_z"] = (stl.resid - stl.resid.mean()) / stl.resid.std()
anomalies = weekly[weekly["resid_z"].abs() > 3]
print(anomalies[["sessions", "resid_z"]])
For the autumn spikes, also compute year-over-year relative lift:
weekly["yoy_baseline"] = weekly["sessions"].shift(52)
weekly["relative_lift"] = weekly["sessions"] / weekly["yoy_baseline"]
A stable ratio across three years supports a purely seasonal cause. A growing ratio suggests the seasonal effect is being amplified by something else — wider promotional adoption, platform growth in certain markets, etc.
Step 2 — Data quality check
A genuine demand spike keeps conversion rate roughly stable or raises it during promotions. A bot wave or tracking bug pushes sessions up while conversion, session duration, and pages-per-session drop.
weekly["cvr"] = weekly["orders"] / weekly["sessions"]
print(weekly.loc[anomalies.index, ["sessions", "cvr"]])
If CVR during the anomalous week is more than one standard deviation below the series mean, investigate instrumentation before theorizing about demand.
Step 3 — Segment the excess
For each anomalous week, compare each segment's session count to its own rolling baseline, then compute each segment's share of the total excess. This isolates where the spike came from.
def segment_lift(dim, spike_week, baseline_weeks=8):
base_end = spike_week
base_start = spike_week - pd.Timedelta(weeks=baseline_weeks)
base = (
df[(df["week"] >= base_start) & (df["week"] < base_end)]
.groupby([dim, "week"])["sessions"].sum()
.groupby(dim).mean()
)
spike = df[df["week"] == spike_week].groupby(dim)["sessions"].sum()
out = pd.DataFrame({"baseline": base, "spike": spike}).fillna(0)
out["excess"] = out["spike"] - out["baseline"]
out["share_of_excess"] = out["excess"] / out["excess"].sum()
return out.sort_values("excess", ascending=False)
summer_week = anomalies.index[anomalies.index.month.isin([6, 7])][0]
for dim in ["country", "channel", "device", "merchant_id", "is_new_visitor"]:
print(f"\n--- {dim} ---")
print(segment_lift(dim, summer_week).head(5))
Interpreting results
| What you observe | Most likely explanation |
|---|---|
| Excess spread across merchants, geographies, channels; CVR stable or up | Broad promotional or seasonal demand |
| Top 3–5 merchants account for more than 50% of excess | Viral product drop or large single-merchant campaign |
| Excess concentrated in social referral, new mobile visitors | Influencer or short-form video virality |
| Excess concentrated in one country | Local event, regional sale, or new market launch |
| Sessions spike, CVR and duration collapse, narrow user-agent distribution | Bot traffic or scraper wave |
| Step change across all segments simultaneously, abrupt start and end | Instrumentation or tracking change |
Two falsifiable hypotheses
H1: Autumn spikes are driven by the major late-autumn shopping weekend.
- Data needed: daily session breakdown, merchant promotion calendar, email and SMS send volumes.
- Confirmed if: the daily peak aligns with the promotional weekend dates each year, and merchants who ran discount codes show disproportionate lift.
- Falsified if: the lift is distributed evenly across November with no peak around the promotional dates, or merchants without promotions show the same lift as those with promotions.
H2: The Year 3 summer spike was caused by a small number of merchants (viral or campaign-driven).
- Data needed: merchant-level daily sessions, referral URL breakdown, and external social-mention volume.
- Confirmed if: five or fewer merchants account for the majority of excess sessions, and their top referrers are social or influencer-originated links.
- Falsified if: excess is distributed across thousands of merchants and referrers, pointing instead to a platform-wide event or external macro driver.
Common mistakes to avoid
- Jumping to a seasonal explanation without first checking data quality. A tracking bug is a more common cause of a one-off spike than a macro event.
- Comparing raw peak heights across years without adjusting for a growing baseline. A taller spike in Year 3 may reflect platform growth, not stronger seasonality.
- Stating hypotheses that cannot be falsified. Every hypothesis should specify what data would rule it out, not just what would confirm it.