The insights beacon
Mount once, track everything, never break the site.
Updated
On this page
Mounting
The tracker mounts once in the site's root layout, browser-side, with the public key:
"use client";
import { useEffect } from "react";
import { usePathname } from "next/navigation";
import { lps } from "@/lib/lps";
export default function AnalyticsTracker() {
const pathname = usePathname();
useEffect(() => {
lps.insights.init({ autoPageviews: false, autoClicks: true });
}, []);
useEffect(() => {
lps.insights.notifyRouteChange(); // SPA navigations become pageviews
}, [pathname]);
return null;
}