I'm trying to capture this button-position value in a GTM variable on a link click, to differentiate different instances of a button being clicked:
button-position value in the HTML
The developer I'm working with doesn't want to use an element ID in the dataLayer as there would be multiple instances and apparently that's bad practice.
I'm not sure where I'm going wrong, I guess I'm not referencing something or the HTML needs changing, but this is what I have in a variable:
gtm.element.dataset.buttonPosition in GTM variable
I've read this can still be a dataLayer variable in GTM, but happy to be corrected, or if there's some custom JavaScript I can use instead.
Thanks for any help...
Tom