Skip to main content
Claude Code can add Wendung to a Next.js app from a single prompt. It reads your codebase, proposes funnel steps, and changes files only after you approve the plan. Your part is the account, the publishable key, the plan approval, and the allowed origins in the dashboard. Once events arrive, you can connect Claude Code to your analytics and ask it which step loses users. To write the code yourself instead, follow the Next.js guide.

What you need

  • A Next.js project using the App Router. The setup also handles Pages Router and other frameworks, but this guide follows the App Router.
  • Claude Code running in the project’s folder.
  • A Wendung account. Sign up without a card; your first workspace starts a 14-day trial of the Starter plan and then moves to the Free plan. See Plans and limits.

Setup

1

Create a project and copy its key

In the dashboard, create a project for the app. Open the project’s Settings → API keys and copy the key named Default. It starts with pk_. A publishable key is safe in frontend code, and ingest accepts it only from your allowed origins, so you can paste it into the chat.A new project starts with Dev mode on, so it accepts events from localhost for its first 24 hours. If your project is older, turn on Dev mode under Settings → Allowed origins. It can take a few minutes to take effect.
2

Run the setup prompt

Paste this prompt into Claude Code:
Prompt
Claude Code asks whether you have an account, a project, and the key, and whether Dev mode is on. Answer in one message. It then installs the wendung-sdk skill, which documents the SDK’s API so it can follow it instead of guessing method names or options. The setup prompt lists every step it follows.
3

Review the plan

Before it edits any file, Claude Code reports what it found and proposes a funnel. For a typical SaaS app, the plan looks like this:Check that each step marks a moment that matters to you and that the names are what you want to see in reports. Names are matched character for character, so changing them later means changing the code and the funnel.Claude Code also asks two things you decide:
  • Pageviews. Whether to turn on pageview tracking for web analytics. The Free plan doesn’t include pageviews.
  • Consent. How your app asks visitors for consent to analytics and restores their choice. If you have no consent banner yet, say so; the consent guide covers the options.
Steps that happen only on your server, such as a payment confirmed by Stripe, need a secret key that you create in the dashboard and add to the server environment yourself. The setup prompt tells Claude Code not to ask for it in the chat. See Track Stripe payments as funnel steps.
4

Approve and let it add the code

After you approve the plan, the setup prompt tells Claude Code to:
  • install @wendung/sdk and read the key from an env var,
  • call Wendung.init() once in the browser, with debug on in development,
  • set consent for the setup you chose and, if your app waits for the visitor’s choice, connect setConsent() to your consent manager,
  • call identify() when the user is known and consent is granted, including after a signed-in user grants consent, and reset() on logout,
  • add each step() call where its milestone happens,
  • run your build, type check, and lint.
In a Next.js App Router project this usually ends up like the Next.js guide: a client provider in the root layout. Review the diff like any other change.
5

Allow your app's origins

In the project’s Settings → Allowed origins:
  • Add your production origin, for example https://app.example.com.
  • Turn Dev mode back on if it has switched off. It accepts events from localhost for 24 hours.
6

Check that events arrive

Run the app locally, accept analytics in your consent banner if the app has one, and trigger one of the steps, for example by signing up a test user. With debug on, the browser console logs [Wendung] ingest accepted batch. The project’s Events page lists each request with its status. A rejected request shows the reason, such as an origin that isn’t allowed.
7

Create the funnel

Under Funnels, create a funnel and pick the step names in order. Names that have already arrived appear in the step picker with their counts. See Creating a funnel. The Free plan includes one funnel per project.

Ask Claude Code where users drop off

Once real traffic has passed through the funnel, connect Claude Code to your Wendung data:
In Claude Code, run /mcp, select wendung, and sign in to Wendung in the browser window that opens. New connections get read access by default. Then ask questions that combine your data with your code, for example:
Prompt
Claude Code reads the funnel, segment, and user timeline data through the MCP server and the code from your project, so it can relate the drop to the code behind that step and propose a change in the same session. Find and fix funnel drop-off with your coding agent walks through a full investigation. Each analytics query counts toward your plan’s monthly MCP queries; listing funnels and cached results don’t. The Free plan includes 50. To also let Claude Code search these docs, add the public docs server:
Agent setup covers other agents, write access, and a prompt that connects both servers at once.