Errors not being received using error tracking code

I am having an issue with error tracking code not sending console errors to my dashboard. Based on documentation it looks like it should be plug and play so I’m not sure what other requirements are required to receive the error messages. I have checked the events and do not see anything coming in. Any information or help would be greatly appreciated.

Hi,

In theory adding _paq.push(['enableJSErrorTracking']); to the tracking code should be enough.

You can test it by running something like setTimeout(function() { notExistingFunction(); }, 0); in the console and check if a request to matomo.php is made. (making the error without setTimeout directly in the console does not work)

Another solution, if you use the Matomo Tag manager: you have to set the needed configuration in the matomo configuration variable:

@Lukas

Thanks for the suggestion! It looks like the errors that happen at the same time as the page loads don’t get caught. I was able to get an error when console logging a variable that didn’t exist.
Is there a way to capture those errors that happen at page load so they can be sent?

Hi,

I don’t think there is a (simple) way to get errors before Matomo has finished loading the matomo.js (which is at the end of the page load).

But if you know a bit of JS, you can see that the code of enableJSErrorTracking is really simple and you could write an equivalent that tracks events in window.onerror and embed it into your site, so it works from the beginning.

Thank you for your help! This was really informative and I really appreciate it.