How to track my form when not redirecting to thank you page

We use the free plugin ‘matomo for wordpress’ and it works perfectly. The only thing we can’t do is track an event when a user fills in the contact form. Matomo’s manual states that forms are automatically tracked when they go to a thank you page. However, we cannot do this as our form only shows a thank you message through javascript. Is there a possibility that this can still be tracked? Good to know that our forms are created and sent by the following plugin: ‘Contact form 7’.

Hi @stefanie.sidekick
Is the form located in some kind of iframe?

Not in a iframe, but it’s added to the page through a shortcode.

I would suggest follow this reference: