Skip to main content

Import from 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).
  • 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.
  • To import properties: 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.

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
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.

Troubleshooting​

MessageWhat to do
PostHog rejected the API keyThe key is wrong, revoked, or missing the Cohort: Read or Person: Read scope. Create a new key.
PostHog cohort or project not foundCheck 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 runPostHog limits API reads per organization. Digia tries again at the next sync.
Could not reach PostHog with those detailsCheck the region and, for self-hosted, that the address is reachable from the internet.
Only {n}% match an app userMost imported people aren't recognized. Check Match users by against what your app passes to setUserId.
Could not read this cohort's peopleProperties couldn't be listed. You can still import the audience and add properties later from Settings.