Anonymous userIds tracking and merging/changing userId

Hi, I’m trying to find out if it’s somehow possible to update userIds. We are thinking of a setup where we generate the userId sent to matomo based on a combination of the userId and a hashed version of the password (different from what’s stored in the database, so it’s only known in the frontend). This ID would be generated on each login and kept in the frontend.

The idea is that this way we can have a stable ID for the user without having any way to de-anonymize the ID ourself, making it a truly anonymous ID rather than a pseudononymous ID (the latter is still considered personal data under GDPR).

One obvious drawback of this approach is that the ID changes every time the user changes their password. This may be acceptable, as it’s likely fairly rare and also gives users a way to reset their tracking identifier, but I was wondering if it is somehow possible to change or merge the userId at the time of the password reset (we would have both passwords, so we can generate both IDs and send a request to matomo requesting the change, similar to when a user logs in and their visit becomes associated with the user).

Aside from that, feel free to share any thoughts on the approach if there are any obvious problems or a better way of doing that.

Thanks in advance for any advice!