# Setup Guide


This guide will help you set up PostHog as a destination in the RudderStack dashboard. It also lists the configuration settings required to correctly send data from the supported sources to PostHog.

## Connection compatibility

{{< destination-config >}}

{{< info >}}
In the web device mode integration, that is, using [JavaScript SDK]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/_index.md" >}}) as a source, RudderStack loads the PostHog native SDK either from the `https://app.posthog.com` domain or your instance URL. 

Based on your website's content security policy, you might need to [allowlist the required domain]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/load-js-sdk.md#allowlist-destination-domain" >}}) to load the PostHog SDK successfully.
{{< /info >}}

## Get started

Once you have confirmed that the source platform supports sending events to PostHog, follow these steps:

1. From your [RudderStack dashboard](https://app.rudderstack.com/), add the source. Then, from the list of destinations, select **PostHog**.
2. Assign a name to your destination and click **Continue**.

## Connection settings

To successfully configure PostHog as a destination, you will need to configure the following settings:

{{< image src="images/event-stream-destinations/posthog-connection-settings.webp" alt="PostHog connection settings" >}}

- **Team API Key**: Enter your PostHog team API key. This is a mandatory field. For more information on obtaining your PostHog Team API Key, refer to the [FAQ]({{< ref "#faq" >}}) section below.
- **Instance URL**: Enter your PostHog instance URL.

{{< info >}}
If you are hosting your own PostHog instance, add the URL of your instance without the trailing slash. So, the URL will look something like `https://[your-instance].com`.
{{< /info >}}

- **Client-side Events Filtering**: This setting lets you specify which events should be blocked or allowed to flow through to PostHog. For more information on this setting, refer to the [Client-side Events Filtering]({{< ref "sources/event-streams/sdks/event-filtering.md" >}}) guide.
- **Use updated mapping for Group calls**: Enable this setting to send the `group` traits as event properties to PostHog. It is strongly recommended to enable this setting to send all your `group` events to PostHog correctly.

{{< warning >}}
**This setting is applicable only when sending events via cloud mode**. RudderStack uses the updated group mappings in device mode by default. For more information on this setting, refer to the [Updated group mapping]({{< ref "destinations/streaming-destinations/posthog/posthog-cloud-mode.md#updated-group-mapping" >}}) section.
{{< /warning >}}

### Web device mode settings

This section lists some of the other configurable settings when sending events to PostHog via [web device mode]({{< ref "destinations/rudderstack-connection-modes.md#device-mode" >}}).

- **Use device mode to send events**: If enabled, RudderStack will send the events to PostHog via [device mode]({{< ref "destinations/rudderstack-connection-modes.md#device-mode" >}}).
- **Enable Local Storage for Persistence**: Enable this option to reduce the amount of data stored in the cookies by storing it locally instead.
- **PostHog Person Profile option**: Choose the required option from the dropdown to create a [person profile](https://posthog.com/docs/data/persons) in PostHog:

    - **Always**: Captures the [identified events](https://posthog.com/docs/libraries/js#anonymous-vs-identfied-events) for all users.
    - **Identified Only**: Captures the [anonymous events](https://posthog.com/docs/libraries/js#anonymous-vs-identfied-events) by default. Identified events are captured only for users having a person profile.

    See the [PostHog documentation](https://posthog.com/docs/libraries/js#how-to-capture-anonymous-events) for more information on these settings.

- **Enable autocapture with PostHog**: Enable this option to allow PostHog to send [auto-captured](https://posthog.com/docs/integrations/js-integration#usage) events.
- **Allow PostHog to automatically capture pageview events**: Enable this setting to allow the PostHog web SDK to send a page view event every time it is loaded on a page.
- **Disable session recording**: Enable this setting to stop PostHog from recording the user sessions. For more information on PostHog's session recording feature, refer to the <a href="https://posthog.com/manual/recordings/">PostHog documentation</a>.
- **Additional headers to pass with XHR requests to PostHog API**: Add a list of key-value pairs in this field. The RudderStack web SDK will then forward these headers on the event requests sent to PostHog.
- **Property denylist** - Add a list of traits or event properties that you want the PostHog SDK to filter.

## FAQ 

#### Where can I find the PostHog Team API Key?

To get your PostHog Project API Key or Team API Key, follow the steps below:

1. Login to your PostHog dashboard.
2. Go to the **Settings** tab under the **Project** section in the left sidebar.
3. You can find the Team API key under **Project API Key** or **Team API Key**.
