Custom logic before rendering registration Page

I am integrating keycloak with my telemedicine app. I want to send some fields to keycloak from my app whenever a user is redirected to keycloak for registration. I have tried, I can receive them in query params. But the issue is that I want to show these params on keycloak registration screen. How can I do that? Passing query params to the registration ftl?
And if I want to execute some logic before the registration page is rendered, what is the way to do that?