Analytics for Next.js
One component in your root layout, or one prompt for your coding agent. Then traffic, conversions and uptime for the site, readable from the editor you already have open.
Let your agent add it
Open Connect agent in your dashboard, click Copy setup prompt, and paste it into your coding agent. It finds your shared layout, installs the tracker once, and verifies MCP access. No StepMetrics npm package is required.
Or add it yourself
Add the tracker in app/layout.tsx inside <body>:
import Script from "next/script";
{process.env.NEXT_PUBLIC_STEPMETRICS_SITE_ID && process.env.NEXT_PUBLIC_STEPMETRICS_ENDPOINT && (
<Script
defer
src={`${process.env.NEXT_PUBLIC_STEPMETRICS_ENDPOINT}/t.js`}
data-site={process.env.NEXT_PUBLIC_STEPMETRICS_SITE_ID}
/>
)} Both variables are required for the tag to render. A preview deployment built without them sends nothing, rather than reporting into production's numbers because it was built from the same commit.
Client-side navigation counts. The tracker hooks the History API, so a route change in the App Router is a pageview without any extra code.
Track the steps that matter
Pageviews are automatic. Name the actions you care about and send them with one call; each one appears on the conversions row by itself and can be a step in a funnel.
window.stepmetrics('signup');
window.stepmetrics('purchase', { plan: 'pro' }, { revenueCents: 2900, currency: 'USD' }); Conversions your server knows first, such as a payment confirmed by a webhook, post to the same endpoint from the backend. See server-side events.
Read it from your editor
Connect Claude Code, Cursor or any MCP client with a read-only key, and ask in words: which pages lost traffic this week, where mobile visitors drop out of signup, whether Tuesday's spike was a crawler. The agent gets the same numbers as the dashboard.
claude mcp add --transport http stepmetrics https://app.stepmetrics.co/mcp \
--header "Authorization: Bearer dak_..." Try it on your site.
Add your first site for free. See where visitors come from, what they look at, and how many take the next step.
No credit card required.