App Router navigations are counted
A Next.js app server-renders once and then navigates on the client. With trackScreenViews enabled, the SDK listens for those soft navigations, so every route change registers instead of only the first page load.
GuidesWeb
Cookieless analytics for Next.js, with event data stored in Germany.
Privytics tracks page views and custom events in Next.js apps through the @openpanel/nextjs SDK. You add one component to your root layout, point it at the Privytics ingestion API, and client-side route changes start registering as screen views. Setup is a few lines, and nothing is written to the visitor's device.
A Next.js app server-renders once and then navigates on the client. With trackScreenViews enabled, the SDK listens for those soft navigations, so every route change registers instead of only the first page load.
@openpanel/nextjs exports the OpenPanelComponent and useOpenPanel hook for the browser, plus the OpenPanel class for Route Handlers and Server Actions. Client and server events land in the same project.
On Vercel a function can return before an in-flight request resolves, which silently drops events. Wrapping the call in waitUntil keeps the function alive until the event is sent.
The default setup sets no cookies and stores nothing on the device, so there is no consent flag to pass down your layout tree or gate the component on. You remain the data controller and decide what your own lawful basis requires.
About five minutes, on the free plan, without a credit card.
pnpm install @openpanel/nextjsapiUrl points the SDK at Privytics instead of its default host, and is the one prop you must set. scriptUrl is optional: the component injects the tracker script tag for you and falls back to OpenPanel's CDN when you leave it out, so set it if you want the script served from Privytics too. This prop only exists on the Next.js component.
// app/layout.tsx
import { OpenPanelComponent } from '@openpanel/nextjs';
export default function RootLayout({ children }) {
return (
<>
<OpenPanelComponent
clientId="YOUR_CLIENT_ID"
apiUrl="https://api.privytics.com"
scriptUrl="https://privytics.com/op1.js"
trackScreenViews={true}
/>
{children}
</>
);
}useOpenPanel is a hook, so the component needs the 'use client' directive.
'use client';
import { useOpenPanel } from '@openpanel/nextjs';
export function UpgradeButton() {
const op = useOpenPanel();
return (
<button
type="button"
onClick={() => op.track('upgrade_clicked', { plan: 'pro' })}
>
Upgrade
</button>
);
}Server-side calls authenticate with a client secret, so keep this instance out of client components. On Vercel, waitUntil stops the function from closing before the event is sent.
// utils/op.ts
import { OpenPanel } from '@openpanel/nextjs';
export const op = new OpenPanel({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
apiUrl: 'https://api.privytics.com',
});
// app/api/checkout/route.ts
import { waitUntil } from '@vercel/functions';
import { op } from '@/utils/op';
export function GET() {
waitUntil(op.track('checkout_started', { plan: 'pro' }));
return new Response('ok');
}Privytics runs the open-source OpenPanel engine, so the upstream Next.js SDK reference applies here too. Point apiUrl at Privytics and the data lands in your Privytics project.
Privytics runs on the open-source OpenPanel engine, and the SDKs are OpenPanel's packages published under the @openpanel npm scope. You install the real package and point apiUrl at https://api.privytics.com. Privytics is independent and is not affiliated with or endorsed by OpenPanel.
Yes. You add OpenPanelComponent to app/layout.tsx and it tracks client-side route changes when trackScreenViews is set. The package also supports the pages directory.
The default setup writes no cookies and stores nothing on the visitor's device. The anonymous visitor id is a salted hash of IP, user agent and project id, and the salt rotates daily. You are still the data controller, so confirm what your own lawful basis and local rules require.
Import the OpenPanel class from @openpanel/nextjs and create an instance with your client id, client secret and apiUrl. Call op.track from any server context, and wrap it in waitUntil on serverless platforms so the function does not exit first.
Yes, via identify with your own profileId, which gives cross-session user profiles. That is opt-in and goes beyond the cookieless default, so you need your own lawful basis for it.