<TrackbridgePageViews />
Fires trackPageView on every Next.js route change. Internally a thin client component that subscribes to usePathname() and calls tracker.trackPageView({ path: pathname }) whenever it updates.
Drop it once inside <TrackbridgeProvider>. There are no props.
Signature
Section titled “Signature”import { TrackbridgePageViews } from '@trackbridge/sdk/next';
<TrackbridgePageViews />;Behavior
Section titled “Behavior”- Renders nothing (
return null). - Calls
tracker.trackPageView({ path: pathname })on mount and wheneverpathnamechanges. - The tracker handles dedup of consecutive identical paths internally, so React 18 strict-mode double-mount is a no-op.
- Returns immediately if
ga4MeasurementIdwas not configured (debug-warns underdebug: true).
The component does not include search params in the path by default — usePathname() from next/navigation returns the pathname only. If you want search params, wire trackPageView manually with useSearchParams() instead.
Example
Section titled “Example”import { TrackbridgeProvider, TrackbridgePageViews } from '@trackbridge/sdk/next';
export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html> <body> <TrackbridgeProvider config={config}> <TrackbridgePageViews /> {children} </TrackbridgeProvider> </body> </html> );}See also
Section titled “See also”tracker.trackPageView()— what this calls under the hood.<TrackbridgeProvider>— required ancestor.