Design Product Analytics and Event Capture for a Small E-Commerce Store
Company: Posthog
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Technical Screen
How would you implement analytics for a small, independently owned e-commerce site? Assume the owner is the main consumer of the results and wants to learn how visitors find and use the store and whether they go on to buy; which of those questions comes first is for you to clarify. Expect the discussion to go deep on how the analytics data is gathered in the first place: which events are captured, where each one is observed, and how it reaches storage. Storage and reporting come after that.
```hint Start at the point of capture
For each number the owner cares about, decide whether the visitor's browser or the store's own server is the more trustworthy place to observe it, and what can stop the event from arriving.
```
```hint Follow one visitor
Trace one anonymous visitor who browses, adds an item to the cart, checks out, and comes back on another day. Ask which identifier each event carries at every step.
```
### Constraints and Clarifications
- The scenario implies a small business with limited engineering capacity, so the design should be proportionate to it. Traffic volume, budget, and staffing are not specified; ask before sizing anything.
- The storefront technology is unspecified. It could be a hosted e-commerce platform or custom code.
- The focus is analytics about visitor behavior and purchases, not operational monitoring of the site.
### Clarifying Questions
- Which questions should the analytics answer first: traffic sources, popular products, checkout conversion, repeat purchases, or revenue trends?
- Is the store built on a hosted platform or on custom code, and can you add code to both the pages and the server?
- What visit and order volumes should the design handle, and how fresh must the reports be?
- Which privacy or consent rules apply to the store's visitors and limit cookies or identifiers?
- Is using an existing analytics product acceptable, or must the capture and storage be built in-house?
### What a Strong Answer Covers
- A concrete event model tied to the owner's questions (for example page views, product views, add-to-cart, checkout started, order completed) and the properties each event carries.
- Capture mechanics: browser-side versus server-side events, batching and delivery, loss when a page closes, ad and tracker blockers, bots, and which source is authoritative for purchases and revenue.
- Identity: anonymous visitor identifiers, sessions, linking to a customer or order, and the limits of cross-device tracking.
- Proportionate storage and reporting, including funnel and conversion queries, and a reasoned build-versus-buy decision.
- Consent handling and data-quality checks, such as reconciling tracked purchases against the store's real orders.
### Follow-up Questions
1. The tracked purchase count is lower than the number of orders in the store's database. How do you find the cause, and which number do you report to the owner?
2. How would you credit a purchase to the campaign or referrer that first brought the visitor, if that visit happened days earlier?
3. How would the design change if the store's traffic later grew by orders of magnitude?
4. How do you keep event names and properties from drifting as new pages and features are added?
Overview: Design analytics for a small independent e-commerce store, with the emphasis on how behavioral and purchase data is gathered in the first place. It tests event modeling, browser versus server-side capture, visitor identity across checkout, proportionate storage and funnel reporting, privacy, and data-quality reconciliation.