What is a “Script Error” and why isn’t there more information?
Modern browsers may report errors from scripts loaded from another origin as the generic Script error. message. This is a browser security measure that prevents potentially sensitive cross-origin information from being exposed.
Why Matomo reports a generic Script error
When an uncaught error originates from a script loaded from a different origin, the browser may withhold its details from the error event. Matomo can only record the error information provided by the browser. When the browser sanitises a cross-origin error, Matomo may receive a generic message such as:
Error: Script error.
at window.onerror (https://example.com/page:0:0)
This does not indicate a Matomo error or a data quality issue. It means the browser has withheld information about the underlying error.
What information is withheld?
The browser may not provide the original error message, script URL, line number, column number or other diagnostic information. Matomo can therefore record that an error occurred but cannot identify its underlying cause.
This table compares the information normally available for a same-origin error with the limited information provided for a cross-origin error.
| Error detail | Normal error | Cross-origin error |
|---|---|---|
| Message | Actual error message | Script error. |
| Script URL | Available | Not provided |
| Line / column | Available | 0 / 0 |
| Error details | Available | Not provided |
How to investigate a generic Script error
You may be able to resolve a Script error if you can identify and fix the script causing it. If the error comes from a cross-origin script, configuring the server correctly may allow the browser to provide more diagnostic information.
It is recommended to investigate a Script error when:
- The error coincides with functionality on your website not working as expected.
- The affected script or the domain hosting it is under your control.
- The error occurs frequently enough that you want to identify its underlying cause.
- The script is provided by a third party that may be able to investigate the problem or configure the required cross-origin headers.
If the error comes from a third-party script you do not control, the browser provides no information, and there is no indication that the error is affecting your website, there may not be enough information available to resolve the error.
In this case, you can choose to ignore the crash in Matomo.
What happens when a Script error is ignored
When you select Ignore this crash, Matomo stops tracking future occurrences that match the ignored crash. A crash is matched using its Message, Type, and `Source.
View ignored crashes under Crashes > Manage Crashes and unignore a crash if you want Matomo to start tracking it again
Matomo does not currently provide a general rule to suppress an entire class of crashes based only on a broad condition such as the message Script error. If generic script errors are recorded with different identifying details, they may need to be ignored separately. You can also merge related crashes to consolidate them in reports.
How to troubleshoot Cross-Origin Resource Sharing (CORS)
If the affected script is loaded from another origin and you control the domain hosting it, configure Cross-Origin Resource Sharing (CORS) so the browser can expose the underlying error details.
- Open the affected page and check the browser developer console for more information about the error.
- Add
crossorigin="anonymous"to the<script>element that loads the JavaScript from the other origin. - Configure the server hosting the JavaScript file to return an appropriate
Access-Control-Allow-OriginHTTP response header. - Reload the page and check the browser developer console to confirm the CORS configuration works correctly.
- Check Crash Analytics again. When CORS is configured correctly, the browser can provide the underlying error details for Matomo to capture.
- When configured, the browser can provide the underlying error details, which Matomo Crash Analytics can then capture.
If you do not control the domain hosting the script, the server owner must configure the required CORS header. Without this configuration, the browser will continue to withhold the error details.