Skip navigation

Delay link activation should not interfere with anchor and javascript links

score 1
You have not voted. New Idea

In DTM the delay link activation breaks the JS-based links and in some instances anchor links functionality.


The request is to either:

1. Have an option to disable the delay link activation on links that are pure anchors, contain the URL of the existing page + an anchor, or contain javascript commands.

2. Revise the functionality of delay activation so that the delay just delays the activation of the link, not stops it and then takes user to that URL.


Including a sample code that successfully can achive both of these requests:


/**  * The functions executes for x milliseconds.  * @param  {Integer} ms  Number of milliseconds the function should run.  * @return  */ export default function waitMilliseconds(ms) {   var start = new Date().getTime();   var end = start;   while(end < start + ms) {     end = new Date().getTime();   } } /**  * Delays the links from moving forward on click by 1 second  * to allow the data to go into analytics successfully without the delays.  */ export default function handleInternalLinkClicks() {   let $body = $('body');    $body.on('click', 'a', function (event) {     var $link = $(event.currentTarget);     var currentUrl = window.location.href.split('#')[0];     var linkDestination = $link.attr('href');      // Delay the click on the pages that redirect us so the analytics has time to capture the data,     // ignore current page anchors.     if (linkDestination.indexOf('#') !== 0 &&          linkDestination.replace(currentUrl, '').indexOf('#') !== 0 &&         linkDestination.indexOf('javascript:') !== '0') {       waitMilliseconds(1000);     }   }); }


Vote history