How to track Matomo events before the end-user opted-in

Hello everyone. I new member Matomo and I have two question :

  1. How to track event with Matomo before the end-user opted-in to my Platform .
  2. How to connect user when user after opt-in?