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

# PostHog

> Query events and persons in a PostHog project live from Explore and AI agents

The PostHog [live source](https://docs.lightdash.com/integrations/live-sources) reads the events of one PostHog project, with their event and person properties.

## Before you start

* **A PostHog account with access to the project**, or a [personal API key](https://posthog.com/docs/api/personal-api-keys) with the scope below.

## Scopes

A personal API key needs these scopes. Sign-in with PostHog asks for them for you.

| Scope | Why |
| - | - |
| `query:read` | Runs the queries that read your events and persons |
| `property_definition:read` | Lists your event and person properties, which become fields |

## Connect PostHog

[Add a live source](https://docs.lightdash.com/integrations/live-sources/set-up-and-manage.md#connect-a-live-source), select **PostHog**, and choose your **Region**. Then click **Continue to PostHog** and pick the project, or choose **API key** under **Connect with** and enter the **Project ID** and **Personal API key**.

![The Add PostHog source dialog with the query:read scope, Connect with and Region under Authentication, Project ID and Personal API key fields with a Test button, and Name under Details](https://mintcdn.com/lightdash/WuPlti30p6CHhcUC/images/integrations/live-sources/posthog-config.png?fit=max\&auto=format\&n=WuPlti30p6CHhcUC\&q=85\&s=c5f7ff9aec4f79e85fa15a4d6e365542)

## Semantic layer

### Events

Product events captured by PostHog, such as pageviews, autocaptured clicks and custom events, with their event and person properties. Dates are in the PostHog project time zone

| Field | Description |
| - | - |
|  Event date | Day the event happened, in the project time zone |
|  Event week | Week the event happened, shown as its Monday |
|  Event month | Month the event happened, shown as its first day |
|  Event time | Exact time the event happened |
|  Event name | Name of the event, such as `$pageview`, `$autocapture`, `$identify` or a custom event |
|  Distinct ID | ID the event was sent with: an anonymous ID until the user is identified, then the user's ID |
|  Person ID | The person the event belongs to, after identifying and merging IDs |
|  Current URL | Full URL of the page the event happened on |
|  Path | Path of the page, without the domain or query string |
|  Referring domain | Domain the visitor came from, or `$direct` |
|  UTM source | `utm_source` value in the page URL, such as `google` or `newsletter` |
|  Browser | Browser name, such as Chrome or Safari |
|  Operating system | Operating system, such as Mac OS X or Android |
|  Device type | Type of device: Desktop, Mobile or Tablet |
|  Country code | Two-letter country code, based on the IP address |
|  Events | Number of events captured |
|  Unique users | Number of distinct people, after identifying and merging IDs |
|  Unique sessions | Number of distinct sessions |

Your event and person properties also show up as fields.

## Limits

| Limit | Value |
| - | - |
| Default date range | Last 30 days, when the query has no filter on Event date |
| Most rows per query | 49,999 |
| Properties | 2,000 event properties and 2,000 person properties |


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