Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

PostHog Destination


Destination Info
  • Accepts Page, Alias, Identify and Track calls.
  • Refer to it as PostHog in the Integrations object
  • This integration is partner owned. Please reach out to the partner's support for any issues.

PostHog(link takes you to an external page) is an open-source suite of product and data tools including product analytics, session replays, feature flags, A/B testing, surveys, and more.

You can find out more about the destination in PostHog's Segment documentation(link takes you to an external page).

This destination is maintained by PostHog. For any issues with the destination, ask a question in the PostHog community(link takes you to an external page) or contact the PostHog support team in-app(link takes you to an external page).


Getting started

getting-started page anchor
  1. From the destinations catalog page in the Segment App, click Add Destination.
  2. Search for "PostHog" in the Destinations Catalog, and select the PostHog destination.
  3. Choose which source should send data to the PostHog destination.
  4. Go to your PostHog project settings(link takes you to an external page), and copy the project API key.
  5. Enter the project API Key that you copied in the PostHog destination settings in Segment.
  6. Enter your PostHog instance address without any trailing slash, for example:
    • https://us.i.posthog.com if you use PostHog US Cloud.
    • https://eu.i.posthog.com if you use PostHog EU Cloud.
    • Your self-hosted URL if you self-host.

If you aren't familiar with the Segment Spec, take a look at the Page method documentation to learn about what it does. An example call would look like:

analytics.page()

Segment sends Page calls to PostHog as a $pageview.


If you aren't familiar with the Segment Spec, take a look at the Screen method documentation to learn about what it does. An example call would look like:

[[SEGAnalytics sharedAnalytics] screen:@"Home"];

Segment sends Screen calls to PostHog as a $screen event.


If you aren't familiar with the Segment Spec, take a look at the Identify method documentation to learn about what it does. An example call would look like:

1
analytics.identify('userId123', {
2
email: 'john.doe@example.com'
3
});

Segment sends Identify calls to PostHog as an $identify event. Data from Identify calls appears in PostHog under the People tab.


If you aren't familiar with the Segment Spec, take a look at the Track method documentation to learn about what it does. An example call would look like:

analytics.track('Login Button Clicked')

Segment sends Track calls to PostHog using the event name you provide.


If you aren't familiar with the Segment Spec, take a look at the Alias method documentation to learn about what it does. An example call would look like:

analytics.alias('507f191e81')

Segment sends Alias calls to PostHog as a $create_alias event.


If you aren't familiar with the Segment Spec, take a look at the Group method documentation to learn about what it does. An example call would look like:

1
analytics.group("0e8c78ea9d97a7b8185e8632", {
2
name: "Initech",
3
industry: "Technology",
4
employees: 329,
5
});

Segment sends Group calls to PostHog as a $groupidentify event. This creates or updates a group with the group type segment_group in PostHog. To create or update a group with a different group type, call track with a $group property.

1
analytics.track('user_signed_up', {
2
$groups: { company: 'Initech' }
3
})

Adding custom session IDs

adding-custom-session-ids page anchor

Segment doesn't include a Session ID with events. This means that events don't have session properties and won't work with PostHog web analytics. As an alternative, you can provide your own $session_id. For more information on formatting the session ID, see PostHog's custom session IDs(link takes you to an external page) documentation.


You can send computed traits and audiences generated using Engage to this destination as a user property. To learn more about Engage, schedule a demo(link takes you to an external page).

For user-property destinations, an identify call is sent to the destination for each user being added and removed. The property name is the snake_cased version of the audience name, with a true/false value to indicate membership. For example, when a user first completes an order in the last 30 days, Engage sends an Identify call with the property order_completed_last_30days: true. When the user no longer satisfies this condition (for example, it's been more than 30 days since their last order), Engage sets that value to false.

When you first create an audience, Engage sends an Identify call for every user in that audience. Later audience syncs only send updates for users whose membership has changed since the last sync.

(information)

Real-time to batch destination sync frequency

Real-time audience syncs to PostHog may take six or more hours for the initial sync to complete. Upon completion, a sync frequency of two to three hours is expected.


Segment lets you change these destination settings from the Segment app without having to touch any code.

Property nameTypeRequiredDescription
API Keystring
required

Go to Project Settings to find your Project API Key


PostHog instance (US/EU)string

Optional

If you're using EU, add https://eu.posthog.com. If you're using US, you can leave this field empty.