Investigate a Conversion Drop with PostHog MCP

Diagnose a conversion drop using PostHog MCP without leaving VS Code.

Introduction

35 Second Summary

When something breaks in your product, you usually have to leave your code editor and open an analytics dashboard to investigate. Every round trip between your editor and the dashboard slows you down.

In this project, you will connect the PostHog MCP to VS Code and run a complete product investigation without ever leaving your editor. You will go from querying live data to shipping a feature flag, all in the same chat conversation.

What You'll Build

Imagine investigating a conversion drop, pinpointing its root cause, and shipping a feature flag to fix it, all by typing questions into your code editor.

By the end of this project, you'll have:

  • A working PostHog MCP connection that lets you query event data, trends, and funnels by typing plain-English prompts into Copilot Chat.
  • A fully diagnosed conversion drop-off backed by funnel, paths, and error data, all retrieved through MCP prompts.
  • A feature flag gating your fix and an alert watching for future conversion regressions, created entirely from your editor.
  • Secret Mission: Launch an A/B experiment on top of your feature flag and build a monitoring dashboard, all through the MCP.

Are there any prerequisites?

You need a PostHog account with existing event data and a GitHub account for GitHub Copilot Free. PostHog's free tier includes 1,000,000 events per month with no credit card required.

Before We Start

Before you start pulling analytics data, take a moment to commit to what you're about to build and why it matters. This step grounds your investigation before any hands-on work begins.

Connect PostHog MCP to VS Code

Every time you want to check your product analytics, you have to leave your code editor and open the PostHog web UI. That context-switch breaks your development flow.

The Model Context Protocol (MCP) eliminates that switch. In this step, you will connect the PostHog MCP server to VS Code through GitHub Copilot Chat, so you can query your live analytics data without ever leaving your editor.

In this step, get ready to:
  • Install and sign in to GitHub Copilot in VS Code.
  • Configure the PostHog MCP server.
  • Verify the connection with a test query.
Enable GitHub Copilot in VS Code

The PostHog MCP server communicates through Copilot Chat. You need the GitHub Copilot extension installed and signed in before you can add any MCP server. The free Copilot tier is all you need for this project.

  • In VS Code, open the Extensions panel by pressing Cmd+Shift+X (macOS) or Ctrl+Shift+X (Windows).
  • Type GitHub Copilot in the search bar.
  • Click Install on the GitHub Copilot extension by GitHub.
  • When prompted, sign in with your GitHub account. If you do not have a GitHub account, create one for free at github.com.

After installation, you should see a Copilot icon in the VS Code status bar at the bottom of the window.

Don't see the Copilot icon?

Make sure you completed the GitHub sign-in. Click the person icon in the bottom-left of VS Code to check your sign-in status.

If the extension installed but the icon is missing, try reloading VS Code: open the command palette with Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows), type Reload Window, and press Enter.

Help me troubleshoot my GitHub Copilot installation in VS Code.

Check for Node.js

PostHog offers a quick setup wizard that runs through Node.js. If you already have Node.js installed, you can use the wizard. If not, you will use a manual setup path instead.

  • Open the VS Code integrated terminal by clicking Terminal in the top menu bar, then New Terminal.
  • Check whether Node.js is installed by running:
node --version

✔️ I see a version number

Node.js is installed. In the next substep, you will use the quick wizard setup to configure the PostHog MCP server.

ⓧ Command not found

No problem. In the next substep, you will use the manual setup path instead. It does not require Node.js at all.

Install the PostHog MCP server

The PostHog MCP server is a free, hosted endpoint that lets Copilot Chat query your PostHog data directly. Pick the setup path that matches your Node.js result.

✔️ I have Node.js (wizard setup)

  • In the VS Code terminal, install the PostHog MCP server by running:
npx @posthog/wizard mcp add

What does this command do?

The npx command downloads and runs the PostHog wizard without installing it permanently. The mcp add subcommand tells the wizard to configure the MCP server for your editor.

The wizard uses OAuth to authenticate. It opens your browser so you can sign in to PostHog and grant the MCP server access to your project data.

  • The wizard will open your browser to authenticate with PostHog. Sign in to your PostHog account and approve the connection.
  • Follow any remaining prompts in the terminal until the wizard confirms the MCP server is configured.

What about the trust dialog?

VS Code may show a trust confirmation dialog asking you to approve the new MCP server. Click to approve it. This is a standard VS Code security check for any MCP server, not specific to PostHog.

🙋‍♀️ Wizard failing or timing out?

Make sure your browser is not blocking pop-ups from the PostHog authentication page.

If the wizard hangs, press Ctrl+C to cancel it and use the manual setup path in the other tab instead.

Help me troubleshoot the PostHog MCP wizard setup.

ⓧ I don't have Node.js (manual setup)

  • Open the VS Code command palette by pressing Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows).
  • Type MCP: Open User Configuration and select it from the results.

VS Code opens the MCP configuration file. Replace the entire contents of this file with the following:

{
  "servers": {
    "posthog": {
      "type": "http",
      "url": "https://mcp.posthog.com/mcp"
    }
  }
}

What does this configuration do?

This tells VS Code about the PostHog MCP server. The type field says the server uses HTTP. The url field points to PostHog's hosted MCP endpoint, which automatically routes to the correct data region (US or EU) based on your PostHog account.

  • Save the file.

You will be prompted to authenticate with PostHog when you send your first query in the next substep. VS Code may also show a trust dialog asking you to approve the MCP server. Click to approve it.

✔️ Awesome, I've got everything!

Great. Double check that you saved the file, then move on to the verification below.

ⓧ I'd like to double check the full code

Your MCP configuration file should contain exactly this:

{
  "servers": {
    "posthog": {
      "type": "http",
      "url": "https://mcp.posthog.com/mcp"
    }
  }
}

Don't see MCP: Open User Configuration?

This command requires VS Code version 1.99 or later. Check your version by clicking Code (macOS) or Help (Windows) in the menu bar, then About. If you are on an older version, update VS Code first.

Help me find the MCP configuration command in VS Code.

Verify the connection

Time to confirm that VS Code can talk to your PostHog project through the MCP. You will ask a simple question and check that the MCP returns real data.

  • Open the Copilot Chat panel by pressing Cmd+Shift+I (macOS) or Ctrl+Shift+I (Windows).
  • At the bottom of the chat panel, make sure Agent is selected from the mode dropdown. MCP tools only work in Agent mode.

What is Agent mode?

Copilot Chat has three modes: Ask, Edit, and Agent. Agent mode lets Copilot call external tools, including MCP servers. Without Agent mode, Copilot cannot reach the PostHog MCP.

Before you type the test query, think about this: does the MCP already know which PostHog project belongs to you? What do you expect it to return?

  • Type the following message into the chat and press Enter:
What PostHog project am I connected to?

If you used the manual setup path, the MCP will open your browser to authenticate with PostHog. Sign in and approve the connection.

The MCP returns your PostHog project name and organization directly in the chat. This confirms the connection is live and authenticated.

MCP not responding or returning an error?

Make sure Agent is selected in the mode dropdown at the bottom of the chat panel. Ask and Edit modes cannot access MCP tools.

If the MCP was not detected at all, try reloading VS Code: open the command palette with Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows), type Reload Window, and press Enter.

If you used the manual path, double check that your mcp.json file contains exactly the configuration from the previous substep.

Help me troubleshoot my PostHog MCP connection in VS Code.

Your editor is now connected to your live PostHog data. Next up, you will start querying your actual analytics events and spotting trends without ever opening the PostHog UI.

Explore Your Live Data

Your PostHog MCP connection is live and authenticated. You confirmed it by querying your project details directly from VS Code.

Before you can investigate a conversion drop, you need to understand what data your PostHog project actually contains. Jumping straight into building a funnel without knowing your event names would produce empty results.

In this step, get ready to:
  • Query your top events by volume to discover what data lives in your PostHog project.
  • Run a daily trend on a key event to spot dips or spikes over the last 14 days.
Ask about your events

The MCP can query your PostHog project's live analytics data and return results directly in Copilot Chat. Your first query will map out the most common events so you know what data you have to work with.

Before you type this query, think about what events you expect to see. What are the key user actions your product tracks?

  • In Copilot Chat, type the following prompt and press Enter:
What are the top 10 events by volume in my PostHog project this week?

The MCP queries your project and returns a ranked list of event names with their occurrence counts directly in the chat panel.

What just happened?

Copilot forwarded your plain-English question to the PostHog MCP server. The MCP executed a query against your PostHog project's live data and returned the results directly in the chat panel.

No browser tab, no dashboard, no context switch. Every analytics question you ask from here on follows the same pattern.

  • Review the list and take note of events that represent key user actions (signups, page views, purchases, button clicks). You'll use these event names to build a funnel in the next step.

Not seeing any results?

  • Make sure you are in Agent mode in Copilot Chat. Click the mode selector at the top of the chat panel and switch to Agent if needed. Copilot only uses MCP tools in Agent mode.
  • If Copilot returns an error about the MCP server, check that the PostHog MCP is still connected. Open the command palette (Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows) and run MCP: Open User Configuration to verify your config matches the setup from Step 1.
  • If the MCP returns an empty event list, check that your PostHog project has received events this week. Try widening the time range by asking about "the last 30 days" instead.
  • The PostHog MCP is not returning my event data in VS Code Copilot Chat. How can I troubleshoot this?
Run a trends query

A ranked list tells you what events exist, but it does not tell you whether something changed recently. A trends query shows how an event's volume moves day by day, making dips and spikes visible.

  • Pick one event from your results that matters to your product (e.g., a signup or purchase event).
  • Type the following prompt in Copilot Chat, replacing the placeholder with your chosen event name:
Show me the daily trend for [[EVENT_NAME="a key event from your results, e.g. completed-purchase"]] over the last 14 days.

What should I look for?

The MCP returns a day-by-day breakdown of that event's volume over the last two weeks. Scan the output for patterns.

  • A sudden dip could signal a bug, outage, or UX regression.
  • A spike might indicate a successful campaign or a tracking issue.
  • A flat line is fine too. It tells you the event is stable and any future change will be easy to spot.
  • Review the daily trend output for any noticeable dips or spikes.

Trend query returning unexpected results?

  • Double check that the event name you used matches one of the event names from your earlier query. Even a small typo will cause a mismatch.
  • If the trend shows all zeros, the event may not have fired in the last 14 days. Try a different event or widen the range to 30 days.
  • My PostHog MCP trends query is not showing the data I expect. How can I adjust my query?

Your events are mapped and you have seen how they move over time. Next up, you'll build a funnel to pinpoint exactly where users drop off in a key flow.

Build a Funnel and Find the Drop-Off

In the last step, you explored your live PostHog data and spotted trends in your key events. Now you know what is happening in your product, but not where in the user journey things break down.

A trend tells you something changed. A funnel isolates the exact step where users abandon the flow. In this step, you will build a funnel query through the MCP and pinpoint the step that bleeds the most users.

In this step, get ready to:
  • Build a funnel query using your real event data.
  • Identify the funnel step with the largest user drop-off.
Define and run a funnel query

A funnel query takes a sequence of events and measures how many users complete each step in order. You will pick three events from the list you explored in the last step and arrange them into a user journey.

  • In Copilot Chat, type this prompt, replacing the highlighted placeholders with real events from your project:
Run a funnel from [[FIRST_EVENT="your first funnel event"]] through [[MIDDLE_EVENT="your middle funnel event"]] to [[FINAL_EVENT="your final funnel event"]] over the last 14 days.

What is a funnel?

A funnel measures a sequence of steps you expect users to take. PostHog counts how many users complete each step and calculates the conversion rate between them.

For example, if you chose a pageview on your pricing page, a checkout click, and a completed purchase, the funnel shows how many users who viewed the page actually clicked checkout. It then shows how many of those went on to buy.

Before you send this prompt, take a guess. Which step in your flow do you think loses the most users?

  • Press Enter to send the funnel query.

The MCP queries your PostHog project and returns conversion rates for each step directly in the chat. You can see exactly how many users made it from one step to the next.

Not seeing funnel results?

  • Double-check that your event names match exactly what PostHog records. Event names are case-sensitive. If you are unsure, ask the MCP "What are my top events?" to get the exact names.
  • If the funnel returns zero users, try widening the time window. Replace "last 14 days" with "last 30 days" in your prompt to capture more data.
  • Help me troubleshoot my PostHog MCP funnel query that is not returning results.
Identify the weakest step

The funnel results show a conversion rate between each pair of steps. One step will stand out with the largest percentage drop. That is your investigation target for the next step of this project.

  • Look at the conversion rates between each step in the funnel output.
  • Find the step with the largest percentage drop from the step before it.
  • Record the name of that step: the funnel step with the largest drop-off.

What if there is no clear drop-off?

If your data does not show a dramatic winner, that is fine. Pick the step with the lowest conversion rate and treat it as your investigation target. The workflow is the skill you are learning, not the specific finding.

You now know exactly where users leave your flow. Next up, you will investigate why they leave by cross-referencing paths and error data through the MCP.

Investigate the Root Cause

Your funnel has revealed the weakest link in your user journey. You know exactly which step bleeds the most users.

Knowing where users drop off is only half the picture. Without cross-referencing user paths and error data, you are guessing at the cause instead of diagnosing it. In this step, you will chain two MCP queries together in the same conversation to build a real diagnosis.

In this step, get ready to:
  • Run a paths query to see where users went after dropping off.
  • Cross-reference the drop-off with error data from the same time window.
  • Form a hypothesis for the root cause of the conversion drop.
Run a paths query

A paths query shows you the exact pages or events users visited after they abandoned the funnel step you identified. This tells you whether users are navigating somewhere specific or simply leaving the site.

Before you run this query, think about where you would expect users to go after abandoning that step. Do you think they leave the site entirely, or navigate to a specific page?

  • In the Copilot Chat panel in VS Code, type the following prompt:
For users who dropped off at [[DROPOFF_EVENT="the event name of your weakest funnel step"]], run a paths query showing where they went instead over the last 14 days.

What should I look for in the paths results?

The MCP returns a breakdown of where users navigated after the drop-off step, ranked by frequency.

  • If users go to a specific page (a help page, a competitor, or an earlier step), that is a friction or confusion signal.
  • If users simply leave the site entirely, the problem is more likely a technical issue like a bug, slow load time, or error.

Review the paths output in Copilot Chat. You should see the most common destinations listed after the drop-off step, with occurrence counts for each.

Not seeing useful paths data?

  • If the MCP returns limited or empty results, your PostHog project may not have enough traffic for that specific event. Try asking the MCP to widen the time window to 30 days.
  • Make sure Agent mode is active in Copilot Chat. If Copilot responds without calling the MCP, click the mode selector at the top of the chat panel and switch to Agent.
  • Still stuck? Help me troubleshoot why my PostHog MCP paths query is returning empty results in VS Code Copilot Chat.
Cross-reference with errors

Paths show you where people went, but not what went wrong technically. Error data adds the other half of the story by surfacing any exceptions or failures that coincided with the drop-off.

Why stay in the same conversation?

Chaining queries in the same Copilot Chat conversation lets the MCP retain context from your paths query. It can automatically correlate errors with the same events and time window you already specified.

  • In the same Copilot Chat conversation, type this prompt:
Are there any errors correlated with [[DROPOFF_EVENT="the event name of your weakest funnel step"]] in the same time window?

The MCP returns either a list of error groups with occurrence counts, or confirms that no errors were found for that event.

What if no errors are found?

No errors is still a valuable finding. It rules out technical bugs and points toward a UX or content problem instead. Maybe the copy is confusing, the form is too long, or the call-to-action is not clear enough.

🙋‍♀️ MCP not returning error data?

  • Error tracking needs to be enabled in your PostHog project for this query to return results. If your project does not have error tracking, the MCP will tell you.
  • If the MCP responds without querying PostHog, rephrase your prompt to be more specific. Try including the exact event name and the date range.
  • Need a hand? Help me get error data from my PostHog MCP for a specific drop-off event.
Form a hypothesis

You now have two pieces of evidence. The paths data shows where users went after dropping off. The error data shows whether something broke technically. Together, they point toward a root cause.

  • Scroll through your Copilot Chat conversation and review both sets of results side by side.
  • Based on what you found, write a one-sentence hypothesis for why users are dropping off at that step.

What does a good hypothesis look like?

A useful hypothesis connects the data to a specific cause. Here are a few examples based on common patterns.

  • "Users are hitting a JavaScript error on the checkout page that prevents the form from submitting."
  • "Users are navigating from the pricing page to a competitor's site, suggesting pricing friction."
  • "No errors exist and users return to the homepage, which suggests the page copy or CTA is unclear."

If your data did not reveal a clear pattern, that is completely fine. Pick the most plausible explanation based on what you have. The workflow is the skill you are learning, not the specific finding.

You diagnosed a conversion drop entirely from your code editor by chaining MCP queries in a single conversation. Next up, you will take action by creating a feature flag to gate a fix and setting up an alert to catch future regressions.

Take Action with a Feature Flag and Alert

You cross-referenced paths and error data to diagnose why users are dropping off. Diagnosing the problem is only half the job.

In this step, you will use the PostHog MCP to create a feature flag for safe rollout. You will also set up an alert to catch future regressions.

In this step, get ready to:
  • Create a feature flag to gate a fix for a percentage of users.
  • Set up a conversion alert to monitor for future regressions.
Create a feature flag

A feature flag lets you enable or disable a piece of functionality for a specific percentage of users without deploying new code. By gating your fix behind a flag at 20%, you can verify it works on a small group before rolling it out to everyone.

  • In Copilot Chat, ask the MCP to create a feature flag by typing this prompt:
Create a feature flag called fix-[[YOUR_ISSUE="your issue name, e.g. checkout-error"]] enabled for 20% of users.

What does this prompt do?

The MCP sends a request to PostHog to create a new feature flag in your project. The flag key (e.g. fix-checkout-error) is the identifier you reference in your application code to check whether the flag is on for a given user.

Setting it to 20% means only one in five users sees the new behavior. This lets you catch problems early before they affect your entire user base.

  • Check the Copilot Chat response. The MCP should return the flag key and a link to view the flag in PostHog.

Flag not created?

  • Make sure you are in Agent mode in Copilot Chat. The MCP tools are only available in Agent mode, not Ask or Edit mode.
  • Check that your PostHog MCP connection is still active. If you see a connection error, try restarting VS Code and re-authenticating.
  • Help me troubleshoot why the PostHog MCP is not creating my feature flag.
Set up a conversion alert

An alert watches a metric and sends you a notification when it crosses a threshold. This closes the loop on your investigation by making sure the next conversion drop does not go unnoticed.

Before you send this prompt, what do you think the MCP will return? Will it confirm the alert is active right away, or will there be additional setup steps?

  • In Copilot Chat, ask the MCP to set up conversion monitoring by typing this prompt:
Create an alert that notifies me if the [[FIRST_EVENT="your first funnel event"]] to [[FINAL_EVENT="your final funnel event"]] conversion drops more than 10% week-over-week.

What does this alert do?

PostHog will compare your funnel conversion rate each week against the previous week. If the conversion from your first event to your final event drops by more than 10%, you get a notification.

This means the next time a similar issue causes users to drop off, you will know about it before it becomes a long-running problem.

  • Check the response. The MCP should confirm the alert is now active and monitoring your funnel.

The MCP confirms the alert directly in Copilot Chat. No extra configuration needed.

Alert not created?

  • Double check that the event names in your prompt match the exact event names from your PostHog project. A typo or different casing will prevent the MCP from finding the events.
  • Try asking the MCP to list your events first (e.g. "What are my top events?") and copy the exact names into your alert prompt.
  • Help me troubleshoot why the PostHog MCP is not creating my conversion alert.

💡 What did you just accomplish?

You explored your live analytics data, built a funnel, diagnosed a root cause, created a feature flag, and set up an alert. That is a complete product investigation workflow.

Every step happened inside VS Code through the PostHog MCP. You never opened the PostHog UI once.

Secret mission

Launch an A/B Experiment and Build a Dashboard

You have a feature flag and an alert in place. But how do you know if the fix actually works? In this mission, you will launch an A/B experiment on top of your feature flag and build a monitoring dashboard for your team, all through the MCP.

Clean Up Your Resources

Clean Up Your Resources

This project runs entirely on PostHog's free tier and GitHub Copilot Free, so there are no ongoing costs. Decide whether to keep your resources running, pause them to come back later, or delete them entirely.

Resources you used:

  • PostHog feature flag (fix-[issue]).
  • PostHog conversion alert.
  • PostHog A/B experiment (Secret Mission).
  • PostHog monitoring dashboard (Secret Mission).
  • PostHog MCP server configuration in VS Code.
  • GitHub Copilot extension in VS Code.

Keep everything running

No action needed. Choose this if you plan to keep investigating your PostHog data through the MCP.

  • Your feature flag, alert, experiment, and dashboard stay active in PostHog. They live inside your existing PostHog project and cost nothing on the free tier.
  • The PostHog MCP server stays configured in VS Code and is available whenever you open Copilot Chat in Agent mode.
  • GitHub Copilot stays installed and ready for your next project.

Pause - I'll come back to this later

Disable the MCP server and your feature flag so they stop running, but keep the configuration in place for when you return.

  • Open the Command Palette with Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows).
  • Run MCP: List Servers, select the PostHog server, and choose Disable. This stops the MCP server without deleting your configuration.
  • In Copilot Chat, ask the MCP to disable your feature flag before disabling the server. Type: "Disable the feature flag fix-[your-issue] by setting active to false." This stops the flag from being evaluated while preserving its configuration.
  • If you created an A/B experiment in the Secret Mission, open the PostHog web app, navigate to Experiments, find your experiment, and click Pause experiment. This disables the underlying feature flag.

Delete - I don't want to use this again

Remove all project resources and start fresh. Follow these steps to clean up everything you created.

  • Delete the PostHog feature flag. Open the PostHog web app, go to the Feature Flags tab, select the checkbox next to your fix-[issue] flag, and click Delete in the toolbar. If the flag is linked to a running experiment, stop the experiment first.
  • Delete the A/B experiment (if you completed the Secret Mission). In the PostHog web app, go to Experiments, open your experiment, and click Pause experiment to stop it. Once stopped, you can delete the linked feature flag as described above.
  • Delete the monitoring dashboard (if you completed the Secret Mission). In the PostHog web app, go to Dashboards, find your dashboard, open its options menu, and choose Delete.
  • Delete the conversion alert. In the PostHog web app, navigate to your alerts and remove the conversion alert you created.
  • Remove the PostHog MCP server from VS Code. Open the Command Palette with Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows), then run MCP: Open User Configuration. Delete the posthog server entry from the mcp.json file and save.
  • Uninstall GitHub Copilot (optional). Open the Extensions panel in VS Code with Cmd+Shift+X (macOS) or Ctrl+Shift+X (Windows), search for GitHub Copilot, and click Uninstall. Only do this if you do not plan to use Copilot for other projects.

Nice Work!

Nice Work!

Nice work! You just ran a complete product investigation workflow powered by the PostHog MCP, all without ever leaving VS Code.

You've learned how to:

  • Connect the PostHog MCP to VS Code and query live analytics data using plain-English prompts in Copilot Chat.
  • Build a funnel to pinpoint user drop-off and diagnose the root cause by chaining paths and error queries in a single conversation.
  • Create a feature flag to safely gate a fix and set up an alert to catch future conversion regressions.
  • Completed an optional Secret Mission to push your skills further.

Ready to quiz yourself?