Matomo offers a basic feature for tracking JavaScript errors that occur on your website or web app. It will track errors that occur in JavaScript and would be displayed in users’ browser developer tools console.

To enable this feature, you can add the following line to your JavaScript tracking code:

_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.
  • 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.