Way to obtain visitors ID and insert it to contact form (Wordpress)

Hello,

Is there a way to insert the Matomo visitors ID of the person who is submitting a contact form of a Wordpress website. For example text based in the e-mail what is sent from the form or inserted in a database directly by PHP.

If you maybe know a more simple way to achieve this, please let me know.

Thanks for your suggestions in advance!

One way to do it:

Add an hidden input value to your contact form:
<input type="hidden" name="visitorid" id="visitorid" value="">

Set its value like this:
_paq.push([ function() { document.getElementById('visitorid').value = this.getVisitorId(); }]);

Note: getVisitorId() will currently not work correctly when you have activated the Matomo third party cookie feature. If you do not know what this is, you most likely did not activate it, so everything should be fine.

I was considering if my explaination was clear enough but luckily it was!
The value you indicated it that a value what you get from the WP-Matomo Wordpress Plugin?