Screen tracking
Track page transitions in your React app so Screeb can evaluate URL-based and page-level targeting rules for messages and surveys.
Automatic trackingโ
Screeb automatically detects URL changes in the browser. For most use cases, no additional setup is needed โ navigation events update window.location, which Screeb monitors.
Manual event tracking per routeโ
If you want to trigger specific Screeb events on route transitions, track page views from a layout component using your router's location hook:
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
import { useScreeb } from "@screeb/sdk-react";
const RouteTracker = () => {
const location = useLocation();
const { eventTrack } = useScreeb();
useEffect(() => {
eventTrack("page_viewed", { path: location.pathname });
}, [location.pathname]);
return null;
};