is thee a way to load a javascript or Jquery before the event is fired through DTM? Right now I have a script on an Event Rule that works, but it only works if the event is clicked on twice. It seems the script needs to be loaded before the event fires. When I view the event in debug mode both through Adobe Debugger, and Omnibug, as well as Network, the value is passed to the variable on the first click..(according to the debugger) but it is never passed to the report suite. However if I click on the event twice then the value will show up in DTM Switch debugger and passed to the report suite. Here are some of the various scripts I have used that give me the same issue as mentioned above. Please note I have loaded the script both directly through custom script in the Event rule, as well as in a Data Element. In everyone of the cases the value is not passed to reporting unless the event is clicked on twice. So it appears the script needs to load prior to the event being fired... Would appreciate your helps as I have exhausted all that I know and could learn from various forums and online sources.
var o_clicks = document.getElementsByClassName('mb-view'); o_clicks.onclick = function() { var o_parent = this.parentNode; name = o_parent.getElementsByClassName('mb-name').innerHTML; return name; }
var name = document.getElementsByClassName('mb-name')[0](this).innerHTML; return name;
$('.mb-view a').click(function() { var mbsItem = $(this).parents('.mbs-item'); if (mbsItem.length) { // Do something here s.eVar17 = (mbsItem.attr('data-mb-name') + ", " + mbsItem.attr('data-mb-id')); console.log(s.eVar17); } else { // Don't follow the link return false; } });
