DocsJavaScript referenceAll pages

JavaScript reference

pagehum.js needs no setup beyond its tag. These are the knobs it has, and what it sends on its own.

Attributes

AttributeOnDoes
data-siteThe script tagYour site key. Required.
data-requests="off"The script tagStops watching your own fetch and XHR calls for failures. The snippet then leaves fetch and XMLHttpRequest untouched.
data-pagehum-successAny button, link, or formCounts a success when it is clicked or submitted. Each click or submit counts, so put it on the final step.
<button type="submit" data-pagehum-success>Start free trial</button>

pagehum.track()

For moments only your code knows about. Write calls as window.pagehum?.track(…) so nothing breaks if the script hasn’t loaded; the call is then skipped.

CallCounts
track("success")A success, e.g. after your server confirms a signup or payment.
track("goal", "g_…")An event for a named goal configured on the site's board. Use the ID shown there; arbitrary names and properties are not sent.
track("engage")An engaged visit, if the default (15 seconds or half the page) misses real interest. Once per session.
track("broken", "/path")A broken hit on a path, when your app renders its own not-found view without a 404 status.
track("error")A client error on the current page.
track("pageview")A pageview, for navigation the snippet can't see. Route changes through history are already counted.
const response = await fetch("/api/signup", { method: "POST", body });
if (response.ok) window.pagehum?.track("success");

Create a goal on the board, then copy its example call into the code that confirms the action. The goal ID names that definition; it does not identify a visitor or session.

What it sends on its own

WhenSends
Page load and each route changeA pageview with the cleaned path, source, and device class
First load without this site’s session flagA session
First visit of a dayA visitor, with the days since the previous visit day
After the page loadsLoad time, TTFB, LCP, and CLS, with the page and device class
After the page loads (with the timings)The KB the page transferred, and its 5 slowest outside origins: origin only, how many requests, how long they took while the page loaded, and their KB when the browser shows it
The page's Content Security Policy blocks somethingThe directive and what it blocked, as an origin or a keyword like inline or eval; never the full URL, the source file, or the line (up to 5 per page load)
When the page is hidden or leftIts slowest interaction (INP), if there was a tap, click, or key press
A call to your own host gets a 5xx or no responseThe method, path, status, and the page that made it (up to 5 per page load)
Three quick clicks in one spotA rage click on the page (up to 3 per page load)
15 seconds or half the pageAn engaged visit, once per session
An uncaught error or rejected promiseA client error with the page and a short message (up to 5 per page load)
A 404 page or a failed same-site assetA broken hit with its path and the same-site page that led there (up to 8 per page load)
Every minute while openA heartbeat

Sessions usually represent browser tabs, not unique visitors. PageHum recognizes some new windows opened by a page, but a tab that copies another tab’s session storage can still be missed; if browser storage is blocked, reloads can be counted as new sessions.

The hosted snippet sends small batches to https://ingest.pagehum.com/api/ingest; its first batch can use the protected /api/ingest/batch endpoint to suppress duplicate retries. If its first request fails, it retries through https://pagehum.com. It uses that address for the rest of the page and, when browser storage is available, for a day. Requests from localhost count; the demo key counts only on pagehum.com.

Two things are added at ingest, not by the snippet: the browser family and major version on client errors, from the request’s User-Agent, and the visitor’s country on pageviews, as the two letters the hosting edge reports. The IP address is never read.