Tracking Successful Sign In / Sign Up in Browser

We are looking to push successful log in and sign up events into the browser data layer (or first party cookie) before redirect.

As of now, we do not see a way to know a login in or sign up was successful and trigger a push to the browser data layer. We can only set it up based on the “submit” of the log in or sign up button, which will incur inflated events due to users hitting the button with invalid credentials, etc.

Does anyone have any insight into tracking this?

Thanks,