How to retrive data from a custom cookies

Hi all,

I am currently using Matomo to track a website and I need to track the user role of the users that visit the website. There is no login functionality on the website (and cannot be implemented anyways), so the devs proposed to have a pop-up message for new visitors that would say something like:

Chose the type of user you are:
1. Type A
2. Type B
3. Type C

Once the user has chosen a type, it would be stored in a cookie. Since the visitorID is tracked by Matomo by default, I was hoping to be able to somehow use the Matomo Tag Manager to retrieve the User Type data and use it as one of the variables in events (clicks,page views, etc).

I have looked for documentation on this for hours, but did not find anything useful. Is something like this even possible? In that case, is there any documentation about this? How should it be done? In case Matomo is not able to retrieve data from custom cookies, is there an alternative?

Many thanks in advance!