Skip to main content

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​

  1. 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 need POSTHOG_API_HOST, the static sites' hosts and their Content-Security-Policy changed, and the policy reworded.
  2. 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 site property (dashboard, docs, design) separates the sites in every insight.
  3. 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​

WhereWhat to setWhy
Project settings → Authorized URLsThe address of each site built with the keyThe toolbar opens only on these, and web analytics filters need them. Add only domains you own.
Autocapture & heatmapsAutocapture on; dead clicks on; Web vitals autocapture onThe code turns these on too, but the project's switch must allow them.
Heatmaps → Heatmap capture URLsUp to three pages on the free plan, for example the dashboard's /, /signin and the docs site's homeHeatmap 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 replayRecording 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 offReplays 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 retention30 daysThe longest the free plan keeps; the Privacy Policy says 30 days.
Web analytics → cookieless trackingLeave offAnalytics is on by default with cookies, and visitors who turn it off send nothing; cookieless mode is not used.
Project settings → IP data captureYour choice: discarding the IP keeps it out of storage, at the cost of less precise location in web analyticsThe 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 wantedError messages can carry account data, and they count toward the event allowance.
SurveysLeave off until a survey is planned
ToolbarUse it on the dashboardThe 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.

AllowanceWhat uses itHow to keep under it
EventsA visit sends roughly 15 to 40: page views and leaves, clicks, web vitals, heatmap batches, custom eventsAbout 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.
RecordingsOne per session that passes the trigger groupSet 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 requestsOne /flags request per page load, plus one server evaluation per landing page render of a returning visitorAbout 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: $pageview where path = / and site = dashboard → landing_cta_clicked → sign_in_started → sign_in_completed → agent_linked → first_backup_seen; conversion window 14 days; break down by $initial_referring_domain or $initial_utm_source. The drop from sign_in_started to sign_in_completed is sign-in friction; from sign_in_completed to agent_linked, onboarding.
  • Calls to action: trend of landing_cta_clicked broken down by cta.
  • Pre-order: funnel preorder_viewed → preorder_clicked (by currency), and a trend of waitlist_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 $pageview where site = dashboard and the path starts with /dashboard or /backups, weekly, for 8 weeks.
  • Activation: share of people with sign_in_completed who reach first_backup_seen within 7 days (a funnel of the two).
  • Assistant: trend of ai_message_sent, broken down by new_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 by plan and currency.
  • Failures: trend of checkout_failed broken down by reason.

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).

DashboardShowsData
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 clicksNow
Acquisition (product dashboard)Landing to first backup funnel, calls to action, pre-order interest, waitlist, sign-in methodWhen the dashboard sends
Product use (product dashboard)Weekly retention after sign-in, activation within 7 days, AI assistant use, lifecycle, most used pagesWhen the dashboard sends
Billing (product dashboard)Checkout funnel by plan and currency, completed checkouts, failures by reasonWhen 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​

  1. Open the dashboard in a private window: no panel shows, requests to /ingest/... answer 200, and the page view appears in Activity with site = dashboard within a minute.
  2. Sign in: the person's distinct id becomes your account id (1 for the owner).
  3. Open Analytics settings in the footer: it says analytics is on. Choose Turn off analytics: the ph_ cookie disappears and no further /ingest request is made, also after a reload and on the docs and design sites (the choice is shared).
  4. Choose Turn on analytics again, then repeat on the docs and design sites; their requests go to us.i.posthog.com.
  5. 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.