PostHog Connection
The PostHog connection integrates your PostHog project with OpsTower, giving agents access to product analytics data including events, metrics, feature flags, experiments, and error tracking. Once connected, you can use PostHog data in scheduled reports and in agent chat queries via MCP (Model Context Protocol).
Prerequisites
Section titled “Prerequisites”You need a PostHog account with access to the project you want to connect. PostHog Cloud (app.posthog.com) and self-hosted instances are both supported.
Credentials Required
Section titled “Credentials Required”To set up a PostHog connection, you need two pieces of information:
- API Key — a personal API key for authenticating requests
- Project ID — the identifier for the specific PostHog project to query
How to Get Your PostHog API Key
Section titled “How to Get Your PostHog API Key”- Log in to PostHog at app.posthog.com (or your self-hosted instance).
- Click your profile icon in the bottom-left corner.
- Go to Personal API Keys.
- Click Create personal API key.
- Give the key a descriptive name (e.g., “OpsTower”).
- Copy the key immediately — it starts with
phx_and will not be shown again.
Store this key securely. If you lose it, you will need to create a new one.
How to Find Your Project ID
Section titled “How to Find Your Project ID”- In PostHog, go to Project Settings (click the gear icon or navigate via the sidebar).
- The Project ID is displayed at the top of the settings page.
Setting Up the Connection in OpsTower
Section titled “Setting Up the Connection in OpsTower”- In OpsTower, navigate to Connections in the sidebar.
- Click Add Connection and select PostHog.
- Enter your API Key and Project ID.
- Optionally, add a Custom Analytics Prompt — additional instructions for how the agent should analyze your PostHog data (max 2000 characters). For example, you might specify which events are most important, how to interpret custom properties, or which metrics to prioritize.
- Click Save to create the connection.
What Agents Can Do with PostHog
Section titled “What Agents Can Do with PostHog”Once connected and enabled on an agent, the agent can:
- Query event data and compute metrics over time ranges
- Look up feature flag configurations and rollout status
- Review experiment results and statistical significance
- Investigate error tracking data
- Generate scheduled analytics reports with trend analysis and anomaly detection
PostHog connections are used in two primary contexts:
- Scheduled Reports — automated analytics summaries delivered on a recurring schedule, covering key metrics, period-over-period comparisons, and detected anomalies.
- Agent Chat via MCP — real-time queries during conversations with your agents, where the agent calls PostHog through the Model Context Protocol to fetch and analyze data on demand.
Troubleshooting
Section titled “Troubleshooting”- Authentication errors: Verify that your API key is correct and has not been revoked. Generate a new key if needed.
- No data returned: Confirm that the Project ID matches the project containing your data. Check that the project has recent events ingested.
- Self-hosted instances: Ensure your PostHog instance is reachable from the internet, or check your network configuration if you are on a private network.