Skip to main content
The PostHog drain puts your agent’s conversations in your PostHog project. Chat messages show between the page views and clicks of the same person, at the time they happened, and the end-of-conversation labels arrive as one more event you can break funnels down by. Read Drains first for how a conversation goes out and what each event holds.

Before you start

  • An admin role in your Waniwani organization.
  • Your PostHog project API key (it starts with phc_). In PostHog, open Settings → Project and copy Project API key. This key can only send events.
  • Your PostHog region: US Cloud, EU Cloud, or the address of your own PostHog host (it must start with https://).

Connect PostHog

1

Paste the key

In Waniwani, open Settings → Connectors → PostHog. Paste the project API key, pick the region and click Connect. Waniwani checks the key with PostHog and sends one waniwani connected event, which creates no person.
2

Link the chat to your PostHog visitors

Give the chat each visitor’s PostHog distinct ID, so chat events land on the same person as their page views. Add this where the chat is installed:
Run the script-tag line once PostHog has loaded on the page. Then open your site and send one message: the step shows when a chat session with a PostHog ID came in.
3

Send a test conversation

Click Send test conversation. Your newest conversation goes to PostHog right away, and Waniwani lists the events sent and whether they landed on a person. Open in PostHog takes you to that person.

What PostHog receives

When the chat has no PostHog ID, the events still go out, on an ID made from the conversation, with $process_person_profile: false. They count in event totals and create no person, so they can’t join a funnel with your page views. This happens when the chat isn’t linked yet, for visitors PostHog tracks without cookies, and for conversations that never had a browser (voice, ChatGPT, Claude). Waniwani takes the visitor ID as a PostHog distinct ID unless it is an ID the chat made itself or a PostHog cookieless ID. If you identify signed-in users in PostHog, posthog.get_distinct_id() returns their identified ID and the chat events follow them.

Use it in PostHog

  • Do chatters convert better? Make a cohort of persons who did waniwani chat.user_message, and compare its conversion with everyone else.
  • Which topics come before a conversion? Build a funnel that starts with waniwani conversation analyzed, ends with your conversion event, and is broken down by topics.
  • Where do conversations stall? Break waniwani conversation analyzed down by drop_off_reason, or filter on frustrated = true and open waniwani_session_url to read the conversation in Waniwani.

Troubleshooting