Skip to main content
Product12 Apr 20267 min readMorgan ChenProduct Lead, Audiences

The case for SQL-based audiences

audiencessqlproduct

Visual audience builders excel at onboarding. They also excel at silently changing meaning when someone tweaks a funnel step or swaps a timeframe preset. SQL is not glamorous on a billboard, yet it remains the lingua franca of analysts who ultimately sign off whether a cohort is safe for paid media.

Contracts you can diff in git

SQL definitions are text. That means pull requests, code review, and rollbacks—all the ergonomics engineers already trust. When a revenue-critical segment misfires, you want a blame view, not a screen recording guessing which toggle moved.

Sure, templated snippets and guardrails matter. We expose macros for common recurrence windows, consent predicates, and platform-specific exclusions so teams are not handwriting boilerplate hourly. But the surface stays SQL-shaped so semantics stay inspectable.

Portability beats vendor lock-in

Every warehouse speaks SQL with dialect quirks, yet the cognitive model transfers. Operators moving from BI exports to TrackLayer recognise WHERE, JOIN, and HAVING immediately. That shortens time-to-first-audience without inventing a bespoke DSL that rots in documentation.

Performance is a product problem, not a user problem

The objection we hear most is performance: "Our analysts will write cartesian joins and melt the cluster." Fair. Behind the scenes we compile validated statements, push predicates toward indexed stores, and cap exploratory runs with safeguards. Dangerous queries fail fast with actionable traces rather than chewing overnight budget.

Marketing wants speed; analytics wants correctness. SQL-based audiences blunt the trade-off: analysts keep expressive power within guardrails; growth teams reuse approved templates shipped as internal packages. GUIs still exist for slicing quick tests—but canonical definitions remain queryable prose. Your future self auditing Q4 spends will silently thank you.

Collaboration patterns that worked

Weekly “cohort office hours” paired growth strategists with analysts to translate briefs into draft SQL, then promote the result into versioned packages. Ambiguity surfaced early—missing time zones, unclear return windows for gift orders—before spend went live.

We also learned to publish negative examples: anti-patterns that look tempting (joining every page view to every email open) and why they explode cardinality. Education reduced toxic queries more than hard quotas alone.

Looking ahead

Natural language assistance will help author first drafts, but we expect human sign-off on canonical SQL for the foreseeable future—language models hallucinate edge conditions; finance does not accept “mostly right” filters when bonuses ride on them.

If you are evaluating audience tooling, ask vendors for diffable definitions and deletion proofs, not just snazzy UI tours. The demo is the easy part; operability on day four hundred is where SQL surfaces earn their keep.

Testing audiences before budgets move

Production SQL runs through staging mirrors seeded with hashed samples so analysts verify row counts and key ratios before flipping a sponsorship toggle. Assertions live next to definitions: expected minimum population, upper bound cardinality, forbidden overlap with suppressed lists.

When a nightly job detects drift—say, suddenly half the cohort shares a placeholder country code—slack alerts cite the offending commit. That pairing of tests plus version history is tedious to set up once and endlessly valuable during holiday code freezes.

We also publish golden exports: anonymized snapshots of audience distributions that CI compares against tolerances. Marketing still experiments; engineering still sleeps. SQL makes those guardrails legible to both sides because the contract is text, not a proprietary binary blob only the vendor can parse.

Rolling back a bad audience resembles rolling back application code: revert the merge, recompute dependent segments, notify destinations with a clear changelog entry. That muscle memory already exists in engineering orgs—lean on it instead of inventing a bespoke “undo” ceremony that only analytics remembers.

Subscribe

Get new posts in your inbox

Same list as changelog subscribers — product writing, no spam.

Major releases only. Unsubscribe anytime. (API wiring in progress.)
Related posts

All posts

We use essential cookies to keep the site secure and functional. Analytics and third-party tags run only with your consent. See our Cookie Policy.

We use essential cookies to keep the site secure and functional. Analytics and third-party tags run only with your consent. See our Cookie Policy.