Showing a question to visitors on your site is not hard. The hard part is deciding which page and which moment it should appear on, what to ask, and which answers to offer. Some moments never show on the screen at all: a payment was declined, a search came back empty. Only your code knows about those.

Most of these decisions can be made by reading the site’s code. So in Usercase, that work goes to your coding agent. The agent reads the code and proposes. You check and approve.

This guide walks through the whole flow in Claude Code, from installing the script to a first question and to fixing what visitors tell you. Codex, Cursor and other MCP clients work the same way. The examples come from running it on this site, usercase.io.

What you need

  • Node.js 18 or later
  • Google Chrome, or run npx playwright install chromium once
  • Your site’s repository and a Usercase account

1. Connect your agent

Run this in your repository folder.

claude mcp add usercase -- npx -y @usercase/mcp@latest

The first time you ask for something, your browser opens the Usercase dashboard. Sign in, check that the code matches the one in your terminal, and pick a project or create one. The key stays on your computer. Usercase only receives its hash.

2. Install the script

Install Usercase on this site

The agent finds your root layout, adds the script once, shows you the diff and opens your local site to check that it loads. It does not commit or deploy.

To install it yourself, copy the code from Settings → Installation in the dashboard and paste it before </head> on every page.

3. Make your first question

Tell the agent who you want to hear from.

Make a Usercase question for people who look at the pricing page and leave without signing up

On usercase.io, the agent read the pricing page and its sign-up buttons, checked its idea against the last week of real visits, and proposed this:

Claude Code proposing a Usercase question for people who scroll through the pricing page and leave without clicking a Start button, with five answers.
A real proposal from Claude Code on usercase.io, shortened.

The card is for people who scrolled through at least 40% of the pricing page and left without clicking any of the Start buttons. Its first version skipped the scroll step and matched 7 recent visits, but most of those people left within a few seconds. Adding the scroll step brought it down to 4 visits from people who had actually read the page.

It also found that another live question already fires at the same moment. Only one card shows per visit, so it asked which of the two to keep before saving anything.

Once you approve, the question is saved as a draft in your Inbox. Visitors see nothing until you turn it on there. When it is on, the card shows on the next page they open, with a line saying it is about the page they just left:

A Usercase question card on the usercase.io blog page, labelled About the previous page, asking "What stopped you from picking a plan today?" with five answers and Other.
The same question as a visitor would see it after leaving pricing for the blog.

4. Send the moments only your code knows

This step is optional. Usercase records page views, clicks and scrolling. Whether a request succeeded or failed, or whether a search came back empty, happens inside your code and has to be sent as an event.

Find the moments only my code knows and send them to Usercase as events

The agent first looks at the events your site already sends, so it does not suggest them again. Then it suggests up to eight at a time, each with its name, where it goes and what it lets you do.

Claude Code suggesting events such as docs search empty, docs copy failed and demo video failed, with the file for each.
Event suggestions on usercase.io, shortened.

One of them was our docs search. When it finds no pages, nothing tells us what the visitor was looking for. With an event there, we can ask "What were you looking for?" right at that moment and learn which docs are missing. It skipped the admin page on purpose, because only our team uses it.

The agent adds only the events you pick, shows them in one diff, and makes each moment happen on your local site to check the event is sent.

5. Read the answers and fix

Questions are kept rare so they don’t get in the way:

  • At most one question per visit.
  • Never in the first 5 seconds on a page.
  • Never while the visitor is typing.
  • Someone who closes two questions in a row isn’t asked again for 30 days.

Usercase reads the answers on a schedule that depends on your plan: every 3 days on Pro, every 2 days on Max, and once on Free, after your first visits come in. You can also press Analyze now in the Inbox to run it sooner. Once a question has enough answers (30 by default), what to change shows up under To fix in your Inbox. You can hand that to the agent too.

Fix the top issue from Usercase

The agent reads the issue and what visitors chose and wrote, finds the code behind it, and explains the change before touching anything. It changes code only after you approve.

Without an agent

You don’t need an agent for any of this. You can paste the script yourself and make questions under New question in the dashboard. For a moment made of several steps, or for events inside your code, the agent is much faster.

Every command is listed in the docs, under Connect your agent.

Ask your real visitors why they got stuck

Usercase shows one short question at the moment it happens. Virtual users let you rehearse before they arrive.

Get started free