How to get data attribute in Custom JavaScript variable?

A value from an elements data attribute (data-category) needs to be read when firing the tag. I tried to create a variable of Custom JavaScript type.

With element.getAttribute('data-category') it could be easily read. But what is the scope the called function is running in to get a reference to the element?

I found out, the custom function gets two variables as parameters: parameters and TagManager.
But I couldn’t find any reference of the current element to call getAttribute() on it.

I also tested a tag manager variable of type DOM Element. This could get the custom data attribute, but it just returns the value of the first matching element. This is quite useless as there are multiple elements of the same class on the page.

It seems the first approach is quite close to the solution. Anyone else using data-attributes and has a hint on this?