Cookie banners are friction, and third-party analytics cookies are increasingly blocked anyway. The good news: for product analytics you don’t need them. Here’s how to track page views, journeys, and identified users in a Next.js App Router app — cookielessly.
Why cookieless matters
Cookieless analytics means less consent-banner friction, data that survives browser tracking-prevention, and a cleaner privacy story. You still get durable device identity — just without storing it in a cookie that gets sent to third parties.
How cookieless device identity works
Instead of a tracking cookie, Nohmo issues a first-party device ID on first load and keeps it in local storage. It never leaves the origin, and the SDK never captures the values typed into forms — only that an interaction happened. That’s enough to reconstruct full session journeys without cross-site cookies.
Setting it up in the App Router
Wrap your root layout once. Page views, clicks, scroll depth, and time-spent are captured automatically:
// app/layout.tsx
import { NohmoNextProvider } from 'nohmo'
export default function RootLayout({ children }) {
return (
<html>
<body>
<NohmoNextProvider
projectId={process.env.NEXT_PUBLIC_NOHMO_PROJECT_ID}
apiKey={process.env.NEXT_PUBLIC_NOHMO_API_KEY}
>
{children}
</NohmoNextProvider>
</body>
</html>
)
}
Note that NEXT_PUBLIC_ variables are inlined at build time, so set them before you build and rebuild after changing them.
Identifying users without losing history
A visitor browses anonymously, then signs up. Call linkUser() and every event that device ever fired — including before signup — attaches to that account retroactively. No cookies, nothing lost:
import { useNohmo } from 'nohmo'
const { linkUser } = useNohmo()
async function onLogin() {
const user = await loginAPI()
await linkUser(user.id, user.email)
}
What you don’t have to do anymore
No third-party cookie to disclose, no cross-site tracking to justify, and far less to explain in a consent banner. You get the journeys and identity resolution of a heavyweight analytics stack, with a privacy posture that holds up.