# Import from PostHog

URL: https://www.digia.tech/docs/user/connect-your-data/posthog

Connect PostHog to Digia Engage and import a cohort, with optional person properties, as an audience you can target.

This guide connects your PostHog project to Digia Engage and imports a **cohort** as an audience. Digia reads the cohort every hour, so membership stays up to date without any work in PostHog.

By the end, you should have:

- PostHog connected under **Data → Connectors**
- a cohort imported as an audience, with users matched to your app
- optionally, person properties such as `plan` available in campaign text

## Before you start

Make sure you have:

- Audiences enabled for your Digia Engage project (see [Before you start](/docs/user/connect-your-data/#before-you-start) ).
- Access to the PostHog project, with permission to create a personal API key.
- At least one **cohort** in PostHog. Digia imports cohorts, not insights or feature flags.
- The user ID your app passes to Digia's `setUserId` . You'll need to know which PostHog field holds the same value. See [Match your users](/docs/user/connect-your-data/#match-your-users) .
- To import properties: [user verification](/docs/user/connect-your-data/#turn-on-user-verification) turned on.

## Step 1: Get your PostHog details

You need three things from PostHog.

**1. Where your PostHog runs.** PostHog Cloud US ( `us.posthog.com` ), PostHog Cloud EU ( `eu.posthog.com` ), or your own self-hosted address.

**2. Your project ID.** In PostHog, open **Project settings** . The project ID is a number, such as `387324` . It is also in the address bar: `…/project/387324/…` .

**3. A personal API key.** In PostHog, open **Settings → Personal API keys** and create a key. Give it only these scopes:

- **Cohort: Read**
- **Person: Read**
Copy the key when PostHog shows it. It starts with `phx_` and is shown only once.

Screenshot coming soon
PostHog: creating a personal API key with **Cohort: Read** and **Person: Read** scopes. Until then, see PostHog's guide to [personal API keys](https://posthog.com/docs/api#private-endpoint-authentication) .

## Step 2: Connect PostHog in Digia

1. Open **Data → Connectors** .
2. On the **PostHog** card, click **+ Connect** .
3. Under **Where is your PostHog?** , choose **PostHog Cloud (US)** , **PostHog Cloud (EU)** or **Self-hosted** . For self-hosted, type the address, for example `https://posthog.example.com` .
4. Enter the **Project ID** and **Personal API key** .
5. Click **Connect** .
![Connect PostHog dialog with host, project ID and personal API key fields](/docs/img/engage/user-guides/data/posthog-connect.webp) Digia checks the details against PostHog before saving the connection.Digia checks the details against PostHog before it saves them. When they work, you see *PostHog connected. Import a cohort now, or come back to it later.* , and the cohort list opens.

## Step 3: Choose a cohort

Pick the cohort you want to target and click **Continue** .

Each row shows the cohort's size and type:

- **Updates automatically** : a dynamic cohort. Digia picks up people who join or leave.
- **Static, will not update** : a fixed list. It stays as it was when you created it in PostHog.
A cohort that is already imported shows **Already imported** . Each cohort can be imported once.

Screenshot coming soon
Digia: the **Choose a cohort** step listing PostHog cohorts.

tip
If the list says *This PostHog project has no cohorts yet* , create a cohort in PostHog first, then reopen the dialog.

## Step 4: Match users and import properties

**Match users by** decides how PostHog people are matched to your app users.

- **Default: every distinct id** imports all of a person's PostHog distinct IDs. A person matches if any of them equals the ID your app passes to `setUserId` . This works when your app calls PostHog's `identify` with the same user ID it gives Digia.
- Choose a person property, such as `email` , if that is what your app passes to `setUserId` . People without that property are left out.
Then pick any **properties** to import. Digia lists the properties people in this cohort actually have, with an example value and how many people have it. Name each one; the name is what you type in campaign text, for example `{{plan}}` . Skip this if you only need the audience.

Screenshot coming soon
Digia: the **Import properties** step with **Match users by** and the property picker.

Click **Import "{cohort}"** . You see *Importing "{name}". The first sync starts shortly.*

## Step 5: Check the audience

Open **Data → Audiences** . After the first sync, the audience shows its size, when it synced, and how many of its people match an app user. Click the row for details.

Screenshot coming soon
Digia: a PostHog audience expanded on the **Audiences** tab.

Digia syncs the cohort **every 60 minutes** . To sync right away, click **Sync now** on the row.

To change the match field or properties later, open **Data → Connectors** and click **Settings** on the PostHog row. Changes apply to every cohort imported from PostHog.

Now [use the audience in a campaign](/docs/user/connect-your-data/#use-your-data-in-a-campaign) .

## Troubleshooting

| Message | What to do | **PostHog rejected the API key** | The key is wrong, revoked, or missing the **Cohort: Read** or **Person: Read** scope. Create a new key. | **PostHog cohort or project not found** | Check the project ID and the PostHog region (US or EU). If the cohort was deleted in PostHog, delete the audience in Digia. | **PostHog rate limit exceeded; giving up for this run** | PostHog limits API reads per organization. Digia tries again at the next sync. | **Could not reach PostHog with those details** | Check the region and, for self-hosted, that the address is reachable from the internet. | **Only {n}% match an app user** | Most imported people aren't recognized. Check **Match users by** against what your app passes to `setUserId` . | **Could not read this cohort's people** | Properties couldn't be listed. You can still import the audience and add properties later from **Settings** .
