How to track goals of a form that does not refresh the page?

I want to track a /contact goal. However i wonder how i can specify this when the form only shows a message without page refresh.

You can track form conversions manually with a click event. For more details please see here: Developer FAQ: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v5