How do I enable basic JavaScript error tracking and reporting in Matomo? (browser console error messages)
Matomo offers two ways to track JavaScript errors that occur on your website or web app:
-
Crash Analytics: This Matomo plugin effortlessly tracks JavaScript errors out of the box, requiring no setup – just start resolving issues and improving your site’s performance. Currently, Crash Analytics is only available for On-Premise users.
-
Basic JavaScript Error Tracking: To use the basic feature for tracking JavaScript errors, you can add the following line to your JavaScript tracking code:
window._paq = window._paq || [];
window._paq.push(['enableJSErrorTracking']);
Once you enable JS error tracking, JS errors will be tracked as Events and appear in the Behavior > Events report. Events will have the following details:
- Event category =
JavaScript Errors
- Event action = the URL of the page where the error occured, with the line number appended (and the character column number)
- Event name = the error message as it appears in your visitors’ browser’s console (developer tools)
So when you open the Event Names report, you can click on the error message to see the page URL(s) on which the error occurred.
Notes:
- currently the stack trace is not recorded, which makes it sometimes harder to troubleshoot.
- the same error will be only tracked once per page view. If the very same error is happening multiple times, then it will be tracked only once within the same page view. If another page view is tracked or when the page reloads, then the error will be tracked again.
- when you enable this feature it will start tracking errors as events. If you already use Events for other purposes, these new error events might somehow “pollute” your Event reports and add noise. As a workaround, you may create Custom reports to filter out the “JavaScript Errors” events if needed.