Pass the Visitor ID in outbound link

Hi,

I have the Matomo tracking code installed on my PHP pages but in some of them I would like to pass the Visitor ID of the user that is on the page just at that moment in outbound links as parameter something like this as an outbound a href:

https://example.com?var1=[MatomoVisitorID]

  1. How do I retrieve the visitor from my local db?
  2. What is the best way of passing it trough to the var1 parameter in the URL?

Thanks for the help!