I have some listening code that is being served as a custom script for the data element that could make multiple updates per page view which is capturing the value of a HTML5 Custom Attribute. The issue is I can't get listening code to return the value for data element to be set. Not sure what I'm doing wrong and have tried numerous approaches. When ever I check the value of the data element I get the default value that was set in the UI. Any idea how I make the data element update every time a qualifying element is clicked?
function addEvent(el, ev, fn, uc) { if (el.addEventListener) { el.addEventListener(ev, fn, uc); } else if (el.attachEvent) { // IE8- el.attachEvent('on'+ev, fn); } } addEvent(document, 'click', function(e) { e = e || window.event; var target = e.target || e.srcElement; var customLinkName = target.getAttribute("data-analytics-tracking-name"); if(customLinkName){ //return or set customLinkName from attribute; //_satellite.setVar("custom link name", customLinkName); } }, false);