Three quick steps
- Open DataLayer Checker in Chrome.
- Click Page Alpha or Page Beta below.
- Confirm a new
content_in_viewportevent fires for that page section.
This demo uses useTrackKitRouteRefresh() in the app provider. Navigate between pages below without a full reload and check for content_in_viewport events on each page.
content_in_viewport event fires for that page section.// components/TrackKitRouteRefresh.tsx
"use client";
import { useTrackKitRouteRefresh } from "nextjs-trackkit/react";
export function TrackKitRouteRefresh() {
useTrackKitRouteRefresh();
return null;
}
// app/providers.tsx
"use client";
import { TrackKitProvider } from "nextjs-trackkit/react";
import { TrackKitRouteRefresh } from "@/components/TrackKitRouteRefresh";
export function Providers({ children }: { children: React.ReactNode }) {
return (
<TrackKitProvider gtmId={process.env.NEXT_PUBLIC_GTM_ID}>
<TrackKitRouteRefresh />
{children}
</TrackKitProvider>
);
}No events yet.
Viewport elements added after the first client navigation may not be observed automatically. useTrackKitRouteRefresh() calls refreshDeclarativeTracking() whenever the pathname changes, so new data-track-view sections are registered on each SPA page.