> ## Documentation Index
> Fetch the complete documentation index at: https://basedash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PostHog

> Connect PostHog to Basedash

Connect PostHog to Basedash to analyze your product analytics data. Basedash connects directly to your PostHog project and queries events, persons, and other tables with HogQL, PostHog's SQL dialect. No sync to Basedash Warehouse is required.

## Prerequisites

* A PostHog Cloud (US or EU) or self-hosted PostHog instance
* The project ID of the PostHog project you want to analyze
* A personal API key with access to that project

## Connection setup

1. In PostHog, go to **Settings > Personal API keys** and create a key with the `query:read` scope for your project
2. From your Basedash dashboard, click "Add Data Source"
3. Select "PostHog" as your data warehouse
4. Enter your connection details:
   * Region: **US Cloud**, **EU Cloud**, or **Self-hosted**. For self-hosted instances, enter your PostHog host (e.g., `https://posthog.example.com`)
   * Project ID. You can find it in the PostHog dashboard URL
   * Personal API key
5. Click "Test Connection" to verify
6. Save your connection

## Best practices

* Create a dedicated personal API key for Basedash
* Limit the key to the projects Basedash needs
* Regularly rotate API keys

## Troubleshooting

* Verify the region matches the URL you use to log in to PostHog (`us.posthog.com` or `eu.posthog.com`)
* Confirm the project ID belongs to the organization the API key has access to
* Check that the API key includes the `query:read` scope

## Next steps: Add custom context

You can add custom context to help the AI better understand your data structure and business logic. Consider adding context at the database or schema level if you notice the AI struggling to locate or understand specific data.

### When to add context

* **Custom events and properties**: When the AI needs to know which events and properties map to key actions
* **Business-specific metrics**: If activation, retention, or conversion definitions need explanation
* **Person properties**: When the AI should know which properties identify plans, companies, or cohorts

For detailed guidance, see our [custom context documentation](/docs/features/custom-context).
