Set up PostHog

Set up PostHog as a destination in RudderStack.

RudderStack supports sending events to PostHog via the following connection modes:

Connection ModeWebMobileServer
Device ModeSupported--
Cloud ModeSupportedSupportedSupported
In a web device mode integration, that is, using JavaScript SDK as a source, the PostHog native SDK is either loaded from the domain or your instance URL. Based on your website’s content security policy, you might need to allowlist the required domain to load the PostHog SDK successfully.

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

  1. From your RudderStack dashboard, 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:

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 section below.
  • Instance URL: Enter your PostHog instance URL.
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.
  • 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 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.
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 section.

Web device mode settings

This section lists some of the other configurable settings when sending events to PostHog via web device mode.

PostHog web SDK settings
  • Use device mode to send events: If enabled, RudderStack will send the events to PostHog via 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.
  • Enable autocapture with PostHog: Enable this option to allow PostHog to send auto-captured 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 PostHog documentation.
  • 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.


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.

Questions? Contact us by email or on Slack