Here is an exemple of how my current custom JS variable looks like :
function() {
e = window.event;
if (e && e.target && e.target.tagName !== “BODY”){
return e.target.offsetParent.attributes.class.value;
};
}
Yet when i use tagbird to check how things are working i see a Javascript error “Failed to evaluate variable - myVariableName”. Is it normal ? Won’t it have any impact on my tags or website ? Can i prevent it ?
<script type="text/javascript">
var _paq=_paq || [];
try {
_paq.push(["trackEvent", "Item Clicked", {{ Click Element }}.offsetParent.attributes.class.value]);
} catch (error) {
// do some errorhandling, in case there is no offsetParent.attributes.class.value
}
</script>
You can’t use tagmanager variables in a TM “Custom JS” variable, but using it this way the browser doesn’t have to re-calculate the values for all non-required variables.
In this case i’d like to use it as an event action : there are several share buttons on my website and the offsetParent class matches the related social network name.
Thanks to that, with one tag i can differenciate all of them.