Next.js
Load the tracker in the App Router without a consent banner.
Add the script
Load the tracker once from a client component near the root layout. next/script keeps it off the critical path.
import Script from "next/script";
export function AnalyticaScript() {
return (
<Script id="analytica" strategy="afterInteractive">
{`window.analytica = window.analytica || [];
window.analytica.push(["init", { projectId: "prj_your_app" }]);`}
</Script>
);
}Track route changes
The tracker observes history changes, including App Router navigations. Call track() for conversions that should count as event goals.
window.analytica?.push(["track", "signup_completed", { plan: "starter" }]);