data-404 to the CrispStats script tag and mark your not-found page with <meta name="crispstats:404">. Each view of a marked page sends one 404 event with the page’s path property, so the Events screen lists the broken paths and how often they are hit. The pageview itself is still counted as usual.
Set it up
1
Turn on the module
Add Use
data-404 to your script tag (data-404="" in JSX), or turn on 404 pages in Settings, Tracking code and copy the updated snippet:d.js, the default script. The smaller d.core.js build leaves this module out and ignores the attribute.2
Mark your not-found page
Add this tag to your 404 page, and only that page:The tag needs no
content: the script only checks that a meta element with this name is in the document. It can be in <head> or in <body>. For Next.js, see 404 pages in Next.js.3
Visit a missing URL
Open a path that does not exist on your live site, then open Events in the dashboard. Select the
404 event and its path property to see which paths were requested.How a page is recognised
A page counts as not found when any of these is true:
The status is a bonus, not a replacement for the marker: other browsers do not expose it, and a single-page navigation has no HTTP status. Keep the meta tag or selector.
When the check runs
The script checks after every pageview, and gives a page that renders its not-found view late a few chances:
It reports at most once per pageview: the first check that finds the page not found sends the event and stops the others. A new pageview cancels the checks still pending for the previous one. So:
- one view of a missing page sends exactly one
404event, however many checks run, - a slow page that shows its not-found view within 3 seconds is still counted,
- visiting the same missing URL again, in the same page load or later, counts again.
data-exclude or on a page the script is not tracking.
Use a selector instead of a meta tag
If adding a<meta> tag is awkward, for example in a single-page app that renders the not-found view in the body, give data-404 a CSS selector for an element that only that view contains:
What is sent
A
404 event is a custom event, so it counts toward your plan’s monthly events like any other. See plans and limits.
Next steps
Outbound links and downloads
Turn on the other click-tracking modules.
Script attributes
Every attribute the script tag accepts.
Events in the dashboard
Filter and break down the
404 event by path.