Get name of UI element by RayCasting

I want to find out the name of an UI element when I click on to it with my mouse. It’s easy with 3D objects that aren’t on the canvas but the same method doesn’t work with UI elements unfortunately, even if I attach a box collider to the UI.
I’ve been looking all around the internet for hours now and just can’t find a good answer of this.

Hi,
I believe you need to use a graphicraycaster.
see here:

hope that helps,