Quick answer
A JavaScript error happens when the browser cannot parse or run a script as written, so the code that failed stops and the feature it powered may not work. Visitors usually see no message. What matters is which errors stop a task and how many sessions they touch, not how often they occur.
Formula: Error rate = JavaScript error count ÷ pageviews
What a JavaScript error is
A JavaScript error happens when the browser cannot parse or run a piece of script the way it was written. The engine creates an error object, the line that failed stops, and whatever that code was meant to do (open a menu, validate a form, send an order) may not happen. The visitor usually sees nothing: no message, just a button that does nothing.
That is why a JavaScript error is different from the errors people usually monitor. An HTTP 500 error is the server failing to answer; a soft 404 is a missing page that returns a success code. A JavaScript error can happen on a page that loaded perfectly, with a 200 status and a fast response, so server-side monitoring never sees it. The count only exists if the visitor's browser reports it.
Types of JavaScript error
MDN lists the built-in error types. In practice, six situations account for most of what a monitoring report shows:
| What it is | When it is thrown | What the visitor notices | Example message |
|---|---|---|---|
SyntaxError | The script cannot be parsed | The whole file does not run, so everything it controls is dead | Unexpected token '<' |
TypeError | A value is not the type the code expects | One feature fails, often a button or a form | Cannot read properties of null (reading 'value') |
ReferenceError | The code uses a name that does not exist | One feature fails; common with third-party tags that did not load | gtmFoo is not defined |
RangeError | A number is outside the allowed range | Rare; often a runaway loop or a recursion that never ends | Maximum call stack size exceeded |
| Unhandled promise rejection | A promise failed and nothing handled the failure | A request that silently never completes | Uncaught (in promise) |
| Cross-origin "Script error." | A script from another origin threw, and the browser hid the details | Unknown; you cannot tell which line or which feature | Script error. |
Two more things are often reported next to errors but are different: a failed resource load (an image or script file that returned 404 or was blocked) and a console warning. Neither stops other code from running by itself.
Which errors reach a monitoring report
Not every error that happens is counted, and tools do not count the same set:
- Errors you catch yourself never appear. Code wrapped in
try/catchthat swallows the error looks healthy in every report, even if the feature is broken. - Synchronous errors and promise rejections are separate events. Per MDN, the window
errorevent is only generated for script errors thrown synchronously; a rejected promise with no handler firesunhandledrejectioninstead. A tool that listens to only one will report a structurally lower number than a tool that listens to both, so two tools rarely agree. - Cross-origin scripts are muted. For a script from another origin, the HTML Standard hides error details to avoid leaking private information, and the browser reports only
Script error.with no file, line or column. The fix belongs to the script's owner: serve it with anAccess-Control-Allow-Originheader and load it withcrossorigin="anonymous", as Sentry's troubleshooting guide describes. - An empty list is not proof of a healthy site. If the collector was never turned on, or the snippet is old, the count is zero because nothing was listening.
Breaking errors and noisy errors
A site can easily produce thousands of errors a week, and most do not cost anything. The useful split is by what the error stops, not what it is called:
- Breaking: it stops a task the visitor came to do (pay, sign up, send a message, load the main content). Fix first.
- Degrading: it breaks something secondary (a carousel, a tooltip, an analytics tag). Fix when convenient.
- Noise: it comes from code you do not control, from very old browsers you do not support, or from a loop that repeats one failure many times. Filter or ignore it, but keep a note of why.
Three questions put an error into one of those groups:
- How many sessions does it touch? Count sessions or visitors, not occurrences. One browser stuck in a retry loop can produce hundreds of errors from a single person.
- Where does it happen? The same error on
/checkoutand on an old blog post has a very different cost. - Did it start after a release? A step in the trend line that lines up with a deploy points at the change that caused it.
Then open one affected session and look at what the visitor did next. If they left or retried the same action, the error is breaking.
Worked example: five error groups, one week
Sample data: a week with 150,000 pageviews and 45,000 sessions. The error report shows five groups.
| Group | Error | Page | Occurrences | Sessions | Share of that page's sessions |
|---|---|---|---|---|---|
| A | TypeError: Cannot read properties of null (reading 'value') | /checkout | 90 | 85 | 85 ÷ 1,200 = 7.1% |
| B | Chat script failed to load, retried repeatedly | all pages | 2,400 | 40 | 40 ÷ 45,000 = 0.09% |
| C | Script error. from a third-party tag | all pages | 600 | 520 | 520 ÷ 45,000 = 1.16% |
| D | ReferenceError: gtmFoo is not defined | /pricing | 150 | 140 | 140 ÷ 2,100 = 6.7% |
| E | SyntaxError on an old browser | blog | 70 | 66 | 66 ÷ 45,000 = 0.15% |
Total occurrences are 90 + 2,400 + 600 + 150 + 70 = 3,310, so the error rate is 3,310 ÷ 150,000 = 2.2% (errors per pageview).
Sorting by occurrences gives B, C, D, A, E. Sorting by sessions gives C, D, A, E, B. Group B has the biggest count and the smallest reach: 2,400 ÷ 40 = 60 errors per session, a retry loop in a few browsers. Neither ranking puts the real problem first, so look at the outcome. Of the 85 sessions with error A, 9 completed a purchase (10.6%); the other 1,115 checkout sessions converted 280 times (25.1%). For error D, 11 of 140 pricing sessions signed up (7.9%) against 156 of 1,960 others (8.0%), so D costs nothing measurable today.
The order of work: A first (it blocks payment), then C (find out whose script it is and ask for the CORS header, because you cannot fix what you cannot see), then D as a cleanup. B needs a stop condition for the retry, and E may simply be ignored.
Common mistakes
- Ranking by occurrences. The top row is often one loop in one browser. Rank by sessions first, then by page.
- Treating zero as healthy. Check that collection is on before reading an empty report.
- Ignoring
Script error.It cannot be debugged from your side, yet it can be hundreds of sessions. Raise it with the script's owner or remove the tag. - Comparing one tool's rate with another's. Different listeners and different denominators (pageviews, sessions, requests) give different numbers. The error rate definition has to match before the values do.
- Chasing old-browser errors. An error on a browser version that is under 1% of sessions can be a policy decision, not a bug.
- Closing a group without checking again. A fix that ships is only fixed if the group stays quiet for the next week.
- Confusing a slow page with an error. Load time is a separate measurement; a page can be slow with no error and broken with perfect speed.
Errors that real visitors hit show up only after someone hits them. For problems you want to find before visitors do, scripted checks from outside, such as synthetic monitoring, complement an error report rather than replace it.
JavaScript errors in TapCub
Take the example above and run it in TapCub. The full walkthrough is in find JavaScript errors.
- Check collection is on. In Web analytics › Configuration › SDK code, make sure JavaScript errors is turned on and the snippet contains
data-errors="true". If it is off, a notice at the top of Monitoring › Errors says so. - Read the cards. Monitoring › Errors shows error count, error rate (error count ÷ pageviews), affected visitors and affected sessions. The trend is error count over time, so a step after a release stands out.
- Sort groups by sessions. Each group has a count, the sessions involved and when it was last seen. Expand one to see each occurrence's time, page, place, device and session. This is where error B (60 errors per session) separates from error A.
- Open a session. Open session shows what the visitor did before and after the error, which answers whether it was breaking.
- Close the loop. Mark a finished group Resolved or Ignored to take it out of Active. A frustration table under the groups lists pages where a script error followed a click within 1 second (an error click) or where people clicked the same element at least 3 times within 500 milliseconds (a rage click); a page needs at least 20 pageviews to be listed.
TapCub's error page has no previous-period comparison, so change the date range yourself to compare weeks. TapCub reports errors but does not fix them or decide for you which one is breaking; that call is the session check in step 4. The page is real visits only, so errors on a page nobody has opened do not appear.
Sources
- MDN Web Docs, Error: built-in error types.
- MDN Web Docs, Window: error event: synchronous script errors only.
- MDN Web Docs, Window: unhandledrejection event: rejected promises without a handler.
- WHATWG, HTML Standard: runtime script errors: muted errors for cross-origin scripts.
- Sentry Docs, JavaScript troubleshooting: CORS attributes and headers:
crossorigin="anonymous"andAccess-Control-Allow-Origin.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Technical Engineer
Focuses on tracking code, SDKs, and API integrations, with practical guidance on implementation checks and troubleshooting.