connecting posthog
This guide walks through connecting twig to your PostHog account so you can access analytics while you develop.
prerequisites
- A PostHog account (sign up at posthog.com if needed)
- A project in PostHog with data
- Twig installed and running
authentication
Twig uses OAuth to connect to PostHog securely.
signing in
- Open twig settings (gear icon or preferences menu)
- Go to the PostHog section
- Click "connect to PostHog"
- You'll be redirected to PostHog in your browser
- Review the permissions and click "authorize"
- Return to twig - your account is now connected
what permissions does twig request?
Twig requests access to:
- Read your projects and organizations
- Read analytics data (events, insights, dashboards)
- Read feature flag configurations
Twig does not request write access - it can read your data but cannot modify your PostHog configuration.
selecting a project
After connecting, select which PostHog project to use:
- Go to settings > PostHog
- Choose your organization (if you have multiple)
- Select the project you're working on
The selected project should match the codebase you're working with.
verifying the connection
To confirm everything is working:
- Open the agent chat
- Ask a simple question about your data:
how many events were recorded today? - The agent should return a count from your PostHog project
If you get an error, see troubleshooting.
switching projects
To work with a different PostHog project:
- Go to settings > PostHog
- Select a different project
- The agent will now query data from the new project
disconnecting
To remove the PostHog connection:
- Go to settings > PostHog
- Click "disconnect"
- Confirm the action
You can reconnect at any time by signing in again.
multiple organizations
If you belong to multiple PostHog organizations:
- You can connect to one at a time
- Switch organizations in settings when needed
- Each organization has its own set of projects
security notes
- OAuth tokens are stored securely on your machine
- No data is stored - analytics data is queried on demand
- Your permissions apply - twig can only access what your PostHog account can access
- Revoke access anytime from PostHog account settings
next steps
With PostHog connected:
- Ask the agent about your user data
- Explore PostHog documentation for what you can track
troubleshooting
Having issues? See connection troubleshooting.