Daily State Snapshots: A Time-Series Model for Account Health
Summary
We snapshot every account and campaign daily at 01:30 — impressions, clicks, spend, conversions, waste_cost and health_score — with idempotent writes and delta computation, rendering 14-day trends that feed anomaly detection and diagnostics.
Quick answer
Define a daily snapshot schema (metrics plus derived waste_cost and health_score), run an idempotent snapshot on a fixed schedule so reruns never duplicate, compute day-over-day deltas, and render 14-day trends. Feed that same history into anomaly detection and alerts so nothing is ever judged without context.
Today we spent $412. Is that good or bad? There is no way to answer from a single number. Spend is meaningless without yesterday, without last week, without knowing whether the account is trending up or bleeding out. This is the problem that led us to stop looking at moments and start modeling time.
Why a single number is not a signal
For years we reviewed accounts the way most marketers do: pull today's report, compare against intuition, call it analysis. The problem is structural — without a state from yesterday, a change from the day before, and a 14-day line, you cannot tell a real shift from normal noise. A +12% click jump means something different when impressions fell 30% the day before; only the sequence shows which story is true.
The design: a daily state snapshot model
We turned every account and campaign into a time-series model. Every day at 01:30 the system snapshots the key metrics — impressions, clicks, spend, conversions, wasted spend, and a computed health score — then calculates the delta against the previous day. Over time these snapshots form a state sequence: not numbers, but a trajectory.
Two details mattered. First, the snapshot is idempotent: if the same day runs twice, it does not duplicate the row — reruns are safe. Second, alongside raw metrics we store two derived values, waste_cost and health_score, so the model carries judgment, not just counters.
Rendering time instead of totals
A 14-day trend view turns those snapshots into lines for impressions, clicks, spend, waste and health. The difference from a normal dashboard is subtle but decisive: you are reading change over time, not a pile of cumulative totals.
One history feeding every consumer
The same snapshot and trend data feeds our anomaly detection and AI diagnostics. An alert about a spend spike is meaningful only because it can be compared against the previous day's state — the historical context and the alerting share one source of truth, so nothing ever gets diagnosed in a vacuum.
The reusable checklist
- Define the daily snapshot fields. Core metrics plus derived values like waste cost and a health score.
- Run an idempotent snapshot on a fixed schedule. Ours runs at 01:30; reruns must never duplicate.
- Compute deltas and render trends. A 14-day line beats any single number.
- Let diagnostics and alerts consume the same history. Context and warnings should never drift apart.
This is the state model underneath our attribution & growth engine — daily snapshots, deltas and 14-day trends, ready out of the box.
Frequently asked questions
What does an idempotent snapshot mean in practice?
It means running the same day's snapshot twice produces exactly one record. If a scheduled run overlaps or gets retried, the data stays clean — no duplicate rows, no inflated trends. This makes scheduled snapshots safe to rerun.
Why store derived values like health_score in the snapshot?
Because a metric sequence without judgment is hard to read. Deriving waste_cost and health_score at snapshot time freezes the interpretation together with the data, so 14-day trends and diagnostics both carry meaning, and historical analysis uses the same definition as today's.
How does a snapshot model help anomaly detection?
An anomaly is defined by comparison. With a daily state sequence, a spend spike can be checked against yesterday's state and the 14-day baseline, so alerts come with context and diagnostics can point at what changed — not just that something moved.