Skip to main content

PostHog

Premium Connector

This connector requires the Standard Plan or higher.

Connect PostHog to Shaped using PostHog's AWS Kinesis destination. Shaped provisions a dedicated Kinesis stream per table; PostHog sends flattened JSON records that match your table schema.

Overview

  1. Create a PostHog table in Shaped with a flat column_schema (top-level columns only).
  2. Copy AWS credentials and the Kinesis stream name from Shaped once the table is ACTIVE.
  3. Create the AWS Kinesis destination in PostHog and set a custom payload — a flat JSON object whose keys match your Shaped columns and whose values reference PostHog fields (see section 2).

PostHog's default Kinesis envelope ({ "event": { ... }, "person": { ... } }) does not match Shaped's schema. In PostHog, configure a custom flat payload: each top-level key must match a column in your Shaped column_schema, and each value should reference the PostHog field you want (e.g. {event.uuid}, {person.id}).


1. Create a Shaped PostHog table

Create the table in the Shaped Console (Tables → Create table → PostHog) or with the CLI.

Define top-level columns in column_schema — do not nest fields under event or person. Column names must be lowercase.

posthog_events.yaml
name: example_posthog_events
schema_type: POSTHOG
unique_keys: [uuid]
column_schema:
uuid: String # Unique identifier for the PostHog event
distinct_id: String # User or session identifier
timestamp: DateTime # When the event occurred
event: String # Event name (e.g. "$pageview")
elements_chain: String # Serialized elements chain (autocapture)
url: String # Page URL where the event was captured
properties: String # Event properties (JSON string)
id: String # PostHog person id (from person.id)
FieldDescription
schema_typeMust be POSTHOG.
column_schemaFlat map of column name → type. Must match the JSON keys in your PostHog Kinesis payload.
unique_keysColumns that uniquely identify a row (e.g. uuid). Used for deduplication in ClickHouse.

Supported types are the same as other realtime connectors — see Custom Table.

The table is provisioned asynchronously: SCHEDULINGDEPLOYINGACTIVE.

CLI

shaped create-table --file posthog_events.yaml

When the table is ACTIVE, open the table in the Console to copy:

  • AWS Access Key ID
  • AWS Secret Access Key
  • AWS Region
  • Kinesis Stream Name

2. Configure PostHog AWS Kinesis destination

  1. In PostHog, go to Data pipeline → Destinations → + Create → AWS Kinesis.

  2. Enter the values from Shaped:

    PostHog fieldShaped value
    AWS Access Key IDFrom table connection details
    AWS Secret Access KeyFrom table connection details
    AWS RegionFrom table connection details
    Kinesis Stream NameFrom table connection details (e.g. ShapedDatasetStream-…)
    Kinesis Partition KeyOptional (e.g. distinct_id or user_id)
  3. Set the payload (custom message body). Build a flat JSON object that matches your column_schema — you do not need to copy the example below exactly.

    How to build your payload

    • For each column in column_schema, add one top-level key with the same name.
    • Set the value to the PostHog placeholder for that data, usually {event.<field>} or {person.<field>}.
    • Only include fields you defined in Shaped; add or remove keys as needed.

    Example (for the schema in section 1 — adapt keys to match yours):

{
"url": "{event.url}",
"uuid": "{event.uuid}",
"event": "{event.event}",
"timestamp": "{event.timestamp}",
"properties": "{event.properties}",
"distinct_id": "{event.distinct_id}",
"elements_chain": "{event.elements_chain}",
"id": "{person.id}"
}

If your table only has uuid, distinct_id, and timestamp, a valid payload might be:

{
"uuid": "{event.uuid}",
"distinct_id": "{event.distinct_id}",
"timestamp": "{event.timestamp}"
}

The rule is: payload keys = Shaped column names, payload values = PostHog template variables for the source data.

  1. Save the payload and click Create & Enable.

PostHog substitutes {event.*} and {person.*} placeholders when sending each event to Kinesis.


3. Verify ingestion

  • New events may take a few minutes to appear in your table after PostHog starts sending them.
  • In the Shaped Console, open your table and check Sample data once events have been sent after the destination is enabled.
  • If columns are empty, confirm the payload keys match column_schema exactly (including lowercase names).