> ## 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. In Basedash, open the **Data** page and click **Add data source**
3. Select **PostHog**
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 **Connect**. Basedash checks the connection, then opens the new data source and starts syncing its schema.

![The PostHog connection form in Basedash with the US Cloud region selected and a project ID and personal API key filled in](https://mintcdn.com/basedash/1uWWcBDZtjMM1cxJ/images/data-sources/warehouses/posthog/connection-form.webp?fit=max\&auto=format\&n=1uWWcBDZtjMM1cxJ\&q=85\&s=ba9facdc9816c803af8391d647a77119)

## Best practices

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

## Troubleshooting

For what each connection error means and how to fix it, see [Connection settings](/docs/data-sources/connection-settings.md#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/ai-context.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.