Expand my Community achievements bar.

Help shape the future of AI assistance by participating in this quick card sorting activity. Your input will help create a more effective system that better serves your needs and those of your colleagues.

Delay link activation should not interfere with anchor and javascript links

Avatar

Level 2

6/28/18

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);     }   }); }
1 Comment

Avatar

Level 4

6/17/19

I always run into the issues with the delay link function, especially where JavaScript is used to deliver one URL on mobile devices and a pop-up on desktop. Usually with delay link active it will send the user to the mobile URL instead of the light-box popup on the desktop experience.