PostHog Setup
The owner's one-time set-up of the PostHog project that the dashboard, the docs site and the design system site send to when built with its key, the settings that keep it within the free plan, and the insights to build first. What the sites send and why is ANALYTICS.md; until the key below is set, analytics stays off everywhere.
1. The project
- Sign in to PostHog Cloud US (
https://us.posthog.com). The code sends to US hosts (us.i.posthog.com,us-assets.i.posthog.com) and the Privacy Policy says the data is stored in the United States; an EU project would needPOSTHOG_API_HOST, the static sites' hosts and their Content-Security-Policy changed, and the policy reworded. - Use one project for all three sites. The free plan has one project, its allowance is shared by every project of the organization anyway, and the
siteproperty (dashboard,docs,design) separates the sites in every insight. - Project settings → General: copy the project API key (
phc_...). It is public by design (it ships in every browser bundle) and can only send data, not read it.
2. The key
The key is read when a site is built (Next.js and Docusaurus put it into the browser bundle). No build on main passes it today: the dashboard's Docker image (src/apps/github-backup-dashboard/Dockerfile) is built without it, and the docs and design sites are built locally and not hosted. Analytics therefore stays off until a build sets NEXT_PUBLIC_POSTHOG_KEY; a running build keeps the bundle it was built with. Leave NEXT_PUBLIC_POSTHOG_HOST and POSTHOG_API_HOST unset: their defaults are /ingest and https://us.i.posthog.com.
Never put the key in a preview or development environment of the same project unless you want those visits in the data: use a second project for that (a paid plan) or leave it empty.
3. Project settings
| Where | What to set | Why |
|---|---|---|
| Project settings → Authorized URLs | The address of each site built with the key | The toolbar opens only on these, and web analytics filters need them. Add only domains you own. |
| Autocapture & heatmaps | Autocapture on; dead clicks on; Web vitals autocapture on | The code turns these on too, but the project's switch must allow them. |
| Heatmaps → Heatmap capture URLs | Up to three pages on the free plan, for example the dashboard's /, /signin and the docs site's home | Heatmap data is kept only for the listed pages on the free plan. In-app heatmaps use screenshots: the sites refuse to be framed (frame-ancestors 'none', X-Frame-Options: DENY), on purpose. |
| Session replay | Recording on; a trigger group with a sample rate (section 4) and a minimum duration of 2 seconds; network capture on for timings only, never headers or bodies; console log recording off | Replays are the scarcest part of the free plan. The code already masks every input and the account pages' text; console output can hold account data. |
| Session replay → Data retention | 30 days | The longest the free plan keeps; the Privacy Policy says 30 days. |
| Web analytics → cookieless tracking | Leave off | Analytics is on by default with cookies, and visitors who turn it off send nothing; cookieless mode is not used. |
| Project settings → IP data capture | Your choice: discarding the IP keeps it out of storage, at the cost of less precise location in web analytics | The proxy forwards the visitor's address (X-Forwarded-For) so location is the visitor's, not the server's. |
| Error tracking (exception autocapture) | Leave off unless wanted | Error messages can carry account data, and they count toward the event allowance. |
| Surveys | Leave off until a survey is planned | |
| Toolbar | Use it on the dashboard | The docs and design sites' Content-Security-Policy allows only PostHog's two ingestion hosts; the toolbar would also need https://us.posthog.com there. |
Mark your own accounts as test accounts (Project settings → Test account filters, for example distinct_id = 1, the owner's account id) and keep filter test accounts on in insights and experiments.
4. Staying within the free plan
The free plan's monthly allowance (Pricing page, October 2026): 1,000,000 product analytics events (web analytics included), 5,000 session recordings, 1,000,000 feature flag requests (experiments are billed with flags), 1,500 survey responses; one project; events kept for a year, recordings for up to 30 days. Without a card PostHog drops data above the allowance; with one, set a billing limit per product (Organization → Billing) and the owner gets alerts at 80% and 100%.
Every visit counts except those of visitors who turned analytics off or whose browser sends Global Privacy Control, so the volumes below are per visit.
| Allowance | What uses it | How to keep under it |
|---|---|---|
| Events | A visit sends roughly 15 to 40: page views and leaves, clicks, web vitals, heatmap batches, custom events | About 25,000 to 60,000 visits a month fit. Watch Billing → Usage after the first week. If it runs high, turn off dead clicks in the project settings first, then restrict web vitals to LCP and INP. |
| Recordings | One per session that passes the trigger group | Set the sample rate to about 4,000 divided by the sessions you expect in a month (for example 20% at 20,000), keep the 2-second minimum, and add a URL trigger to record only the pages you study (for example the landing page and /signin). |
| Feature flag requests | One /flags request per page load, plus one server evaluation per landing page render of a returning visitor | About a million page loads a month; experiments need nothing more. |
5. Insights and dashboards
Build these first; filter each on site and keep filter test accounts on.
Dashboard "Acquisition"
- Funnel, landing to first backup:
$pageviewwhere path =/andsite=dashboard→landing_cta_clicked→sign_in_started→sign_in_completed→agent_linked→first_backup_seen; conversion window 14 days; break down by$initial_referring_domainor$initial_utm_source. The drop fromsign_in_startedtosign_in_completedis sign-in friction; fromsign_in_completedtoagent_linked, onboarding. - Calls to action: trend of
landing_cta_clickedbroken down bycta. - Pre-order: funnel
preorder_viewed→preorder_clicked(bycurrency), and a trend ofwaitlist_joined. - PostHog's built-in Web analytics view, filtered by
site, for visitors, sources, pages and web vitals.
Dashboard "Product use"
- Retention: people who did
sign_in_completed, returning with$pageviewwheresite=dashboardand the path starts with/dashboardor/backups, weekly, for 8 weeks. - Activation: share of people with
sign_in_completedwho reachfirst_backup_seenwithin 7 days (a funnel of the two). - Assistant: trend of
ai_message_sent, broken down bynew_conversation, and weekly unique users of it.
Dashboard "Billing" (once the billing UI sends its events)
- Checkout funnel:
plan_selected→checkout_started→checkout_completed, broken down byplanandcurrency. - Failures: trend of
checkout_failedbroken down byreason.
Experiment: none in the code. The draft landing-hero-cta experiment's code path was removed on 2026-11-05 (ANALYTICS.md); end or archive the draft and its flag in PostHog.
What exists in the project (2026-11-04)
The project is "GitHub Backup" (id 645755, timezone Asia/Kolkata, weeks start on Monday). The docs and design sites have sent since 2026-11-04; the product dashboard sends nothing until it is served with the key (its Docker image is built without it).
| Dashboard | Shows | Data |
|---|---|---|
| Docs & design sites (the project's home) | Visitors and page views per site, top pages, sources, countries, devices, time on a page, web vitals (p75 LCP and INP), rage and dead clicks | Now |
| Acquisition (product dashboard) | Landing to first backup funnel, calls to action, pre-order interest, waitlist, sign-in method | When the dashboard sends |
| Product use (product dashboard) | Weekly retention after sign-in, activation within 7 days, AI assistant use, lifecycle, most used pages | When the dashboard sends |
| Billing (product dashboard) | Checkout funnel by plan and currency, completed checkouts, failures by reason | When the billing UI sends its events |
The experiment landing-hero-cta exists as a draft with its flag off; the dashboard no longer reads that flag, so do not launch it. Path cleaning collapses /backups/<id> and /ai/<id> into one row each. Every insight filters out test accounts.
6. Checking that it works
- Open the dashboard in a private window: no panel shows, requests to
/ingest/...answer 200, and the page view appears in Activity withsite=dashboardwithin a minute. - Sign in: the person's distinct id becomes your account id (
1for the owner). - Open Analytics settings in the footer: it says analytics is on. Choose Turn off analytics: the
ph_cookie disappears and no further/ingestrequest is made, also after a reload and on the docs and design sites (the choice is shared). - Choose Turn on analytics again, then repeat on the docs and design sites; their requests go to
us.i.posthog.com. - With Global Privacy Control on (Brave sends it; in Firefox, Settings → Privacy), a fresh visit sends nothing.
7. Privacy duties
- The dashboard's Privacy Policy (
/privacy#analytics) describes what PostHog receives, where, for how long and how to opt out, and covers the docs and design sites. Update it if the plan changes retention (a paid plan keeps events for up to seven years) or if a setting above changes what is recorded. - Sign PostHog's Data Processing Agreement (Organization → Settings, or posthog.com/dpa).
- A request to delete someone's analytics data: find the person by distinct id (their account id) in People and delete the person with their events and recordings.