What is a Script error?
A Script error is a generic JavaScript error result. Browsers usually hide details for scripts loaded from another domain unless the script and its server allow the page to read those details.
When the browser hides the details, Contentsquare might show Script error instead of the function name, source file, or other error information.
Use this article when the collected result of JS error appears as Script error.
Before you start
You need:
- Access to the server that hosts the script.
- Access to the page or application code that loads the script.
- The support of the script provider when the script is hosted by a third party.
Unmask a Script error
- Identify the script that produces the error.
- Add the Access-Control-Allow-Origin response header to the script.
- Set the header value to an origin that is allowed to load the script.
- Add crossorigin="anonymous" to the script tag.
- Deploy the server and page changes.
- Reproduce the error after the changes are live.
- Check Error Analysis after the processing delay.
Example response header:
Access-Control-Allow-Origin: *Example script tag:
<script
src="https://example.com/app.js"
crossorigin="anonymous">
</script>Use an origin policy that matches your security requirements. The wildcard example is supported by the current Technical Documentation, but your implementation team should choose the appropriate policy for your environment.
Check the result locally
- Open a page that consistently produces the error.
- Open the browser developer tools.
- Open the browser console.
- Reproduce the error.
- Compare the detailed browser error with the result collected by Contentsquare.
Use the local result to identify which script needs cross-origin configuration.
Expected outcome
After the script and server configuration is available, new errors from the script should include more detail instead of only Script error. The current Technical Documentation states that this change can take up to three hours to appear in Error Analysis.
Some third-party scripts cannot be unmasked because the provider does not support the required cross-origin configuration.
Good to knows
- Browser security controls the details available for cross-origin scripts.
- JavaScript stack traces are not a committed Experience Platform capability for the beta.
- Unmasking a script can expose more technical information. Review your security and privacy requirements before changing the configuration.