Creating Sandboxes for Demos
Contents
DemoHog is an internal tool for spinning up a PostHog project filled with realistic, made-up event data. Describe an app in plain English, and it generates events, dashboards, insights, cohorts, Surveys, Feature Flags, Experiments, and (optionally) a hosted demo site wired for Session Replay.
When to use it
Two reasons to reach for DemoHog:
- Tailored demos. A dashboard showing the prospect's funnel, personas, and events lands harder than a generic ecommerce demo. Describe their product, generate the data, walk into the call with a project that already tells the story.
- Take-home sandboxes for prospects. Sometimes a prospect wants to click around before they instrument anything. DemoHog hands them a populated project to explore Product Analytics, Session Replay, Feature Flags, and Experiments with zero setup.
Sandboxes are a fallback, not the goal. Read the next section before you hand one out.
Sandboxes carry real risk
First prize is always getting prospects to send their own data. Two things break when they don't:
- Lower commitment. Installing the SDK is the moment a prospect actually invests in PostHog. Skip it and they're one click from walking. Instrumented prospects convert at much higher rates than sandbox-only ones.
- It doesn't feel like the real product. The data is plausible but it isn't theirs. Numbers won't match anything they recognize, edge cases in their funnel are missing, and the "aha" moment from spotting something real in their traffic never happens.
Push for real instrumentation first. Offer to pair on the SDK install. Send them the relevant installation guide. Only fall back to a sandbox when they genuinely can't instrument yet (pre-launch products, procurement gates, locked engineering time).
If you do hand one over, frame it as a tour, not a trial.
The four-step wizard
Open demohog.vercel.app and click Start wizard (/wizard). The home page also lists past demos under Scheduled and Sandboxes so you can resume or extend a run.
1. Describe your app
Write a paragraph covering:
- What the product does
- 1 or 2 personas
- The main journey (sign up, do thing, convert)
- Any specific events, Surveys, or Experiments you want to show off
Your prompt can be as simple as:
You can add significantly more detail if you want a more deterministic output:
You'll also be asked to fill in:
- Customer name (required). Labels the saved config (e.g. prospect name).
- Date range. How far back (and forward) synthetic history should span. Defaults to roughly 3 months back through 1 month ahead.
Click Analyze my app. DemoHog uses an LLM to infer pages, events (with property specs), objects, personas, funnels, key events (signup, revenue, churn), audience (B2B vs B2C), a dashboard spec, trend/funnel/retention insights, and dynamic cohorts.
2. Review inferred data
Check the inferred cards (pages, events, funnels, key events, audience) and fix anything that's off. For full control, open Edit inferred JSON to edit dashboard, insight, and cohort definitions directly in the model.
Set:
- Number of users. Synthetic users in the dataset (default 100).
- Events per session. Custom events per session (default 5).
Keep custom event names in snake_case so they match PostHog conventions. Click through to save the config.
3. Connect PostHog and generate
Enter:
| Field | Where to find it |
|---|---|
| Host | Ingest host, e.g. https://us.i.posthog.com or EU (https://eu.i.posthog.com) |
| Project ID | PostHog → Project settings |
Project token (phc_…) | PostHog → Project settings → Project token (needed for upload; add it here or on Results) |
Personal API key (phx_…) | PostHog → Personal API keys |
The personal key needs these scopes:
dashboard:writeinsight:writecohort:writesurvey:writefeature_flag:writeexperiment:write
Click Generate demo data. DemoHog will:
- Create (or reuse) a survey, feature flag, and experiment in the project via the PostHog app API.
- Produce JSONL for the date range, validate it, and auto-repair (up to 5 attempts) if validation fails.
Generation doesn't upload events yet. If the end date is still in the future, a daily job gets scheduled automatically (see Optional extras).
4. Results
On Results:
- Download JSONL (optional) to inspect the file.
- Upload to PostHog. Sends events to
/batchusing the project token. Needs thephc_…token if you didn't set it earlier. - Create dashboard, insights & cohorts. Available after upload. The UI waits ~30 seconds for ingest, then creates the inferred dashboard plus trend, funnel, and retention insights and dynamic cohorts.
- Session Replay demo site (optional). Provisions a generated Next.js app on a Fly.io Sprite with
posthog-jsand session recording enabled, wired to your host and project token. Provisioning takes a few minutes. Click around the live URL for at least 10 seconds and move between pages so replays land in PostHog (and confirm Session Replay is enabled in the target project).
Done. You've got a populated project with analytics resources; replays show up once someone (or automation) uses the demo site.
What gets generated
Beyond pageviews and custom events, synthetic data can include:
- Groups (B2B-style organizations)
- Feature flag / experiment exposure (
$feature_flag_called) aligned with the created flag and experiment - Survey responses tied to the created survey
- Revenue and subscription-style events
- LLM-style usage events
- Error events at a low baseline rate
State carries over between runs so scheduled generation stays coherent (same synthetic users and groups over time).
Optional extras
Daily scheduled generation
If the config end date is after today, DemoHog schedules a daily job when you generate (default 03:00 in the job timezone). Production runs this on Vercel cron.
- First scheduled run: backfills from the range start through today (or the range end, whichever is sooner).
- Later runs: 1 new day of events per run until the range end.
- Each day gets validated, repaired if needed, queued, and uploaded in the same cron run.
The home page Scheduled tab shows active jobs and lets you extend the end date to keep a sandbox alive for prospects who come back over a week or two.
Hosted demo site (Sprites)
Provisioning kicks off from the wizard Results step. It needs a Sprites API token on the DemoHog server (SPRITE_TOKEN or SPRITES_TOKEN in the deployment env, not something you paste per demo). If provisioning fails with a missing-token error, ping whoever maintains DemoHog.
The generated site mirrors your inferred pages and events and is built to produce real PostHog Session Replay in the same project you connected.
Automated browser sessions (Browserbase)
If the DemoHog deployment has BROWSERBASE_API_KEY set, the server fires 5 headless Stagehand sessions against the demo URL after Sprite provisioning, and again after scheduled runs that generated new data (when a sandbox URL exists). Those sessions drive the instrumented demo site so PostHog gets events and replays without you clicking manually. Replays also show up in the Browserbase dashboard for debugging.
Optional infrastructure on the shared DemoHog instance, not a per-user setting in the wizard.
Picking the right project
For tailored demos, generate into a fresh project so the data doesn't pollute anything else. Don't reuse a project from a previous prospect.
For prospect sandboxes, create the project in an org the prospect can be invited to, and set realistic timezone and currency so the data feels right.
Getting help
DemoHog is maintained as an internal tool. Code lives in the demohog repo.