How to execute some JS code before redirecting to SSO

Hello,

I have my Discourse platform with SSO configured and working.

How is it possible to execute some client-side JS code when the user is clicking on the Login button before he/she gets redirected.

I would like to do that to send a Google Analytics event.

Thanks.