When to ask invited users to register?

I work with a SaaS B2B company and I'm currently working on enhancing the onboarding experience for invited users to use the app. Note that we want to learn about the user from the beginning so we can personalize the onboarding and focus on specific features related to the user's role.

When should I ask users to insert their password for registration? After clicking on the invitation link from email, or after I capture their information?