Performance
Website error tracking: what a JavaScript error report should contain
What a JavaScript error report should include, what it must leave out, and how a script error differs from the site being down.
The CrispStats team · · 9 min read
In short
A visitor writes to say the button did nothing. The uptime check is green, because the URL answered. The missing record is the exception the browser threw after the HTML arrived. This guide is what that record should hold, what it must not hold, and how it differs from downtime. The product page for the version we ship is error tracking. Uptime, which answers a different question, is uptime monitoring and the uptime basics.
What is website error tracking?
It is the collection of JavaScript failures that happen in the visitor’s browser after the page has loaded: uncaught exceptions, and promises that reject with nobody to catch them.
The browser already knows these. An error event fires for an uncaught exception, with a message, a source URL, a line and a column. An unhandledrejection event fires when a promise fails and no catch handled it. Error tracking is sending a small report of that event to somewhere you will look, grouping repeats so a thousand visitors produce one row, and keeping enough context to find the file.
It is not a log of everything the page did. A click, a network request the server answered, and a slow paint are other systems. It is also not your server’s error log. An exception in a route handler never reaches the visitor’s browser, so a script in the page cannot see it.
How is a JavaScript error different from downtime?
Downtime means a check from outside could not get an acceptable response from the URL. A JavaScript error means the page arrived and a script then threw. One can be true while the other is false.
- The URL does not answer. The uptime check times out, or receives a status that is not a success. Visitors may see nothing. There is often no JavaScript error, because no script ran. That is uptime monitoring.
- The URL answers, and a script throws. The check is green. A button, a form or a navigation still fails for some browsers. That is the error report.
- Both. A partial outage can return an HTML page that then calls an API that is down. The uptime check of the HTML stays green unless you also check the API. The browser may show a rejected promise. You want both records.
Treat them as two alerts. An error spike with healthy uptime is a bad deploy of script. A failed check with no new error is a host, a DNS change or a certificate. Searching the JavaScript report for an outage wastes the hour the check was already trying to save you.
What should a JavaScript error report contain?
Enough to find the throw, and to judge how widely it spread: message, page, source location, stack, browser family, and counts of occurrences and visitors.
| Field | Why it is there | A safe value |
|---|---|---|
| Message | Groups the same failure into one row | TypeError: Cannot read properties of undefined |
| Page path | Shows which template hit it | /checkout |
| Source, line, column | Points at the file and the line | app.js, line 240, column 12 |
| Stack | Shows the call chain for one occurrence | Frames with query strings removed |
| Browser family | Shows whether it is one browser | Safari, not the raw user agent |
| Counts and times | Separates a one-off from a broken deploy | 140 occurrences, 90 visitors, first and last seen |
Group by the message, not by the visitor. The same throw on a thousand loads is one bug. A first-seen time next to your deploy log tells you whether you shipped it. The page path tells you whether it is one template. The browser family tells you whether it is every visitor or only one engine. A stack from a single occurrence is usually enough to open the file. You do not need a stack from all 140.
A browser family is the name: Chrome, Safari, Firefox. It is not the raw user agent string, which is long, unique in combination with other fields, and useless once you have parsed the name out of it. The IP address is the same kind of leftover. It can place the visitor roughly, and it does not explain the throw. Leave both out of what you store.
What must an error report leave out?
Cookies, anything the visitor typed, the raw user agent, and the IP address. The message and the stack still need a look, because your own code can put a secret in them.
- Cookies and local storage. The error is not an excuse to copy the session cookie. A report that includes it is a bundle of credentials.
- Form fields and account details. The email they were typing when the script threw is not context you need. Neither is their name, their address or the contents of the cart beyond a count.
- The raw user agent and the IP address. Store a browser family if you store a device clue at all. Do not store the header, and do not store the address.
- Query strings on your own URLs. A stack frame often contains the script URL, and a page URL in a message can contain a reset token or an email. Strip the query and the fragment before the report is sent.
A try/catch that swallows a failure sends nothing unless you report it yourself. That is right for an expected rejection, and it is how a bug vanishes if the catch was only there to quiet the console. Report the unexpected ones with the same fields, still without the visitor’s data.
Which errors never arrive?
Errors from another origin, missing files, and errors your own catch already handled. A quiet report is not proof the page is healthy.
- “Script error.” A script on another origin throws, and the browser hides the message, the line and the stack. The text
Script error.has nothing you can fix. Drop it, or you will stare at an empty group. - A file that failed to load. A stylesheet or an image that 404s is a network failure, not an exception with a message. It will not look like a TypeError. Watch it in the network panel or as a failed request, not in the exception list.
- Anything caught. Code that handles the rejection has decided it is not uncaught. The window never hears it. If you still want it, send it deliberately.
- Server exceptions. The page script does not run in your API. A 500 from a route handler is in the server log, or in an uptime check of that URL. It is not in this report.
- Source maps, breadcrumbs and replays. A message and one stack do not rebuild the original TypeScript line, list the clicks before the throw, or record the screen. Error tracking states that limit for ours.
Cap the volume. A loop that throws on every frame will fill the report and the visitor’s network. One send per distinct error per page load, and a small ceiling per page, is enough to see the bug. The thousandth copy does not add a new message.
What does one broken button look like in the report?
One new row, tied to one page, starting just after a deploy, with the uptime check still green. The row is the bug. The count is how many people met it.
A worked example: a checkout throw after a deploy
This example uses made-up numbers. At 14:10 you ship a change to the checkout script. By 16:00 the error report has a new group: TypeError: Cannot read properties of undefined (reading 'id'), on /checkout, source checkout.js line 240. It has happened 140 times, to 90 visitors. The browsers are Chrome and Safari. The uptime check of https://example.com/checkout has returned a success status all afternoon.
The site is up. The button is not. Ninety visitors hit the throw, and line 240 is where to look: the stack assumes a cart line exists. You do not need a cookie, an email or the raw user agent to open that file. Mark the group resolved when the fix is out. If the uptime check had failed instead, this TypeError would be the wrong trail.
How does CrispStats record JavaScript errors?
Add data-errors to the script tag. The module listens for uncaught errors and unhandled rejections. Each report is the message, source, line, column and stack, and nothing else from the page. The message is cut, the source URL has its query string removed, and query strings inside the stack are removed too. Each distinct error is sent once per page load, at most ten per page. Script error. and failed resource loads are skipped. The core script without the module is about 2.2 KB gzipped.
<script defer src="https://in.crispstats.com/d.js" data-errors data-site="YOUR_SITE_KEY"></script>In the dashboard, repeats of a message are one group: how often it happened, how many visitors saw it, the pages, the browser family, when it was first and last seen, and a stack from one occurrence. You can mark a group resolved or ignored, and you can alert on a new error or a spike. Errors do not count toward the plan’s events. What this is not: server errors, source maps, breadcrumbs, session replay, cookies, form contents, the raw user agent or a stored IP address. A browser family is kept. The address and the user agent string are not. For the URL answering at all, use uptime monitoring, which checks from outside and does not see this TypeError.
Terms in this guide
Free tools
- AI crawler checkerCheck whether a site's robots.txt lets GPTBot, ClaudeBot, PerplexityBot and other AI crawlers in, by training, search and user fetch, with the deciding rule.
- Bounce rate calculatorCalculate bounce rate from sessions, under the classic single-page rule or the GA4 definition, and see how many bounces stand between you and a target.
- Conversion rate calculatorWork out your conversion rate from visitors and conversions: conversions ÷ visitors × 100. With the formula, a worked example and what a target rate needs.
Use cases
- CrispStats for SaaSSee which channels bring paying customers, where trials stall in the funnel, and how your app performs for real users, from one cookieless script.
- CrispStats for agenciesRun every client site from one account, share read-only dashboards by link, and send weekly reports, with no cookie banner to explain.
- CrispStats for startupsFunnels, retention, revenue attribution and uptime from the first day, on a price that stays small while you find your market.
More guides
All guides- Performance · 11 minWebsite uptime monitoring basicsWhat to monitor on a website, how often to check, how to stop false alarms waking you up, and what a status page should show, with the downtime math.
- Performance · 9 minCore Web Vitals in plain EnglishWhat LCP, INP and CLS measure, the good thresholds, and whether Core Web Vitals affect SEO, using Google's own wording.
- Performance · 11 minHow to improve Core Web VitalsHow to improve Core Web Vitals metric by metric, from Google's web.dev guidance: what to fix first for LCP, INP and CLS, with a worked LCP breakdown.