How it works
- Paywalls emits a
$ai_generationserver-side event after every routed request. - The distinct ID is resolved from the provided user id, so make sure you pass a stable user identifier such as the
X-Paywall-Userheader. - Events include latency, token usage, cost breakdowns, request / response metadata, and error flags drawn from the proxy state.
Setup
- In the Paywalls dashboard, open the paywall you want to analyse.
- Navigate to Configuration → Analytics and enable the PostHog toggle.
- Paste your PostHog
Project API Key, and add aProject IDto annotate events. - Save configuration. No code changes are required in your app.
This is especially helpful for low-code and no-code stacks (Zapier, n8n,
Bubble, Make) where you cannot easily install PostHog libraries.
Event payload
Each$ai_generation event contains the consolidated proxy context. Key properties include:
Building dashboards
- Use the
$ai_is_errorflag to build error funnels and monitor vendor reliability. - Segment by
$ai_model, or$ai_providerto understand usage patterns. - Combine with PostHog notebooks or dashboards to compare LLM costs versus revenue, and trigger alerts when latency spikes.
Make sure every request to Paywalls includes a stable
user value. Without
it, events are dropped because PostHog requires a distinct ID for analytics.Related resources
- PostHog API reference — learn how
$ai_generationevents are captured.