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

# PostHog

> Push user behavior data from your warehouse into PostHog

## Setup

After selecting PostHog from our destinations catalog, you will be required to enter your PostHog [*Project API Key*](https://posthog.com/docs/api/post-only-endpoints) and *Public URL*.

* You can locate your Project API key within your PostHog account by navigating to *your PostHog project* > *Project Settings* > *Project API key*.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-posthog-setup.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=1aa3f4171f1cfb30fa0d5cba6d1d5e7e)

* If you are using the cloud-hosted version of PostHog, your Public URL will be either:
  * For US: [https://us.i.posthog.com/batch/](https://us.i.posthog.com/batch/)
  * For EMEA: [https://eu.i.posthog.com/batch/](https://eu.i.posthog.com/batch/)
* If you are using a self-hosted version of PostHog, replace [https://app.posthog.com/](https://app.posthog.com/) with the URL of your instance.

Hightouch supports syncing both `Objects` and `Events` to PostHog.

## Syncing

Hightouch supports syncing to the following PostHog objects:

* `People` (`Persons`)

### Sync modes

Hightouch supports the following sync modes:

* **Upsert** - pushes new `Person` objects to PostHog and updates properties that change in your warehouse.

### Record matching

`Person` records can be matched from your source to your PostHog workspace by Distinct ID (`distinct_id`), which is a unique identifier
in PostHog for each `Person`.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-posthog-idfieldmapping.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=0d5e124c4bdb3794de95409620f8fecc)

### Field mapping

You may also sync columns from your source to PostHog's `Person` properties. PostHog doesn't provide information on properties set for `People` objects,
so you will need to type the exact name of the property you would like to map to in PostHog. These property names must be spelled correctly and are case-sensitive.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-posthog-fieldmappings.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=4213c5bda137a89d9cd2109dc8531126)

## Sending events to PostHog

The PostHog integration also allows you to send events to PostHog with custom properties.

> [!WARNING]
>
> To ensure syncs send each event, your event model must use a truly unique [primary key](https://docs.hightouch.com/getting-started/concepts.md#unique-primary-key-requirement). See the [events syncs](https://docs.hightouch.com/syncs/types-and-modes.md#event-syncs) documentation for more information.

The four elements of any PostHog event are the *Event Name* (**required**, which can be a single string used to name all events, or pulled from your warehouse per event), a *Timestamp* (**optional**, in ISO 1806 format, or a Unix timestamp in **milliseconds**), a **Distinct ID** (**required**, the unique ID of the user corresponding to the event), and event properties.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-posthog-events.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=27a282f1f71baa9ea952a51349cd268a)

You can also map properties that will become event `properties` in PostHog, just as you would for object properties.

## Tips and troubleshooting

To see the exact API requests and responses from each sync run, use the [live debugger](https://docs.hightouch.com/syncs/debugger.md). To get notified by Slack, PagerDuty, SMS, or email when a sync fails, set up [sync alerts](https://docs.hightouch.com/syncs/alerting.md). If you run into an issue this page doesn't cover, [contact support](#pylon-chat).
