Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

PostHog

Query product analytics and feature flags through the Modem Agent

The PostHog integration connects your PostHog instance to the Modem Agent. Once connected, the agent can query your product analytics, check feature flag states, review experiment results, and search error tracking data from chat.

Prerequisites

  • Admin or Owner role in your Modem organization
  • A PostHog account with a Personal API key

Setup

Generate a PostHog API key

In PostHog, go to Settings → Personal API Keys and create a new key. The key should start with phx_.

Connect in Modem

Go to Settings → Integrations → PostHog in your Modem dashboard.

  1. Select your Region (US Cloud or EU Cloud) to match your PostHog instance
  2. Paste your Personal API key
  3. Click Connect

Modem validates the connection by reaching your PostHog instance. If validation fails, double-check your region and API key.

Start asking questions

The agent can now query your PostHog data. Try it from the dashboard or Slack.

What the Agent Can Access

Category Examples
Product analytics Event counts, funnels, retention, trends via HogQL queries
Feature flags Flag states, rollout percentages, targeting filters
Experiments A/B test results with statistical significance
Error tracking Error rates, types, and affected users

The agent can call any PostHog API endpoint your Personal API key can reach. To limit what it can read or change, restrict the key’s scopes when you create it in PostHog.

What the Agent Can Do

With PostHog connected, you can ask the agent to:

  • Query product usage metrics (signups, active users, conversion rates)
  • Check feature flag rollout states and targeting rules
  • Analyze A/B experiment results
  • Search error tracking data for patterns
  • Generate HogQL queries from natural language questions
  • Cross-reference PostHog analytics with feedback from your other data sources

Example Prompts

These work from the dashboard, Slack DMs, or by mentioning @modem in a channel.

Simple:

PromptHow many users signed up last week?
PromptWhat's the rollout percentage for the new-dashboard feature flag?
PromptAre there any errors spiking today?

Advanced:

PromptCompare signup conversion rates this month vs last month, broken down by day
PromptWhich feature flags are at partial rollout? List them with their current percentages.
PromptLook at the pricing page A/B test results and tell me if we've reached statistical significance
PromptCross-reference the top error types in PostHog with recent bug report topics in Modem

Troubleshooting

Connection test fails
  • Verify your API key starts with phx_ and hasn’t been revoked in PostHog - Confirm you selected the correct region (US or EU) matching your PostHog instance - The connection timeout is 15 seconds. If your PostHog instance is behind a slow network, the test may time out.
Agent says PostHog tools aren't available
  • Check that PostHog is connected in Settings → Integrations → PostHog - Try running Test Connection to verify the connection is still valid - If your API key was rotated in PostHog, disconnect and reconnect with the new key
Queries return empty results
  • Start with a broad query and a recent time range to confirm data exists - Check that the events or properties you’re asking about match what’s in your PostHog project - PostHog Personal API keys can be scoped to a single project. If yours is, the agent can only access data within that project.
Queries are slow

PostHog queries over large date ranges or without filters can take time. Ask the agent to narrow the time range or add filters. Starting with the last 7 days is a good default.

Disconnecting

To disconnect PostHog:

  1. Go to Settings → Integrations → PostHog
  2. Click Disconnect and confirm

The agent will no longer be able to query your PostHog data. No data is deleted from PostHog. You can reconnect at any time with the same or a different API key.

Was this page helpful?