Event tracking schemas: the decision that decides what questions you can ever answer
A messy event schema doesn't cause bugs today. It causes questions six months from now that simply can't be answered, no matter how good your SQL is.
An event is a record of something a user did: "viewed a product," "added to cart." An event schema is the consistent shape every one of those records gets logged into. Getting this shape right, early, determines what questions your data can ever answer later.
🎯 Explain Like I'm Hired An event schema is a standard form every "thing a user did" gets filled out on. Every form has the same required fields (who, when, what happened) plus a flexible section for details specific to that type of event. Example: if "add to cart" logs the product under a field called
item, but "checkout" logs the same concept asproduct_ids(a list, differently named), you can't cleanly connect the two events without writing custom one-off logic, and multiplied across hundreds of event types, that's how "just pull the numbers" quietly becomes a two-week project.
CREATE TABLE events (
event_id uuid PRIMARY KEY,
user_id uuid NOT NULL,
session_id uuid NOT NULL,
event_name text NOT NULL, -- 'product_viewed', not 'ProductViewed' or 'view'
event_time timestamptz NOT NULL,
properties jsonb, -- details specific to this event type
context jsonb -- device, app version, locale (same on every event)
);
Sign up to keep reading
Sign up free to unlock the worked examples, edge cases, and interview traps below.