Screen tracking
Tell Screeb which page or screen your user is on, so you can target surveys and messages on where users are in your app.
Screeb targets surveys and messages on the page or screen the user is on. The help center shows how to check what Screeb receives: Track page views and mobile screens.
Page views are automatic
Section titled “Page views are automatic”On the web, Screeb follows the page URL by itself, including in single-page apps: every navigation that changes window.location counts as a new page, and URL-based targeting rules work without code.
Track a page view as an event
Section titled “Track a page view as an event”To trigger a survey on a specific navigation, or to attach properties to a page view, track an event from your router when the route changes:
import { useEffect } from "react";import { useLocation } from "react-router-dom";import { useScreeb } from "@screeb/sdk-react";
export const RouteTracker = () => { const location = useLocation(); const { eventTrack } = useScreeb();
useEffect(() => { eventTrack("page_viewed", { path: location.pathname }); }, [location.pathname, eventTrack]);
return null;};