Tracing event stopping links from drop down link

Hi there,

I have the following code which directs values in a drop down to some external URLs. This works in Chrome, but in IE and FF, it stops and times out the links.

<select onChange="window.location.href=this.value">
<option value="https://www.external-website.com" rel="nofollow" onClick="trackOutboundLink(this, 'Outbound Links', 'Title of Link'); return false;" target="_blank">Link</option> 

However, the links work if I remove the tracking event code.

Any ideas why this would be effecting the links?

Thanks!

What does the console say in IE and FF?

I’m not too sure - where in console do I look?
Thanks

For IE: https://msdn.microsoft.com/en-us/library/dn255006(v=vs.85).aspx

For FF: https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Opening_the_Web_Console

Usually you can get to the console in most browsers by right clicking on the page and viewing source. Once you do that, just click on the console tab and all the errors will display there.

Thanks, I’ve seen that I get the following error:

ReferenceError: trackOutboundLink is not defined

but when I add the code I used to have, the links no longer redirect on the option being selected.

This is the old code I have

unction trackOutboundLink(link, category, action) {
 
try {
dataLayer.push({'event':'interaction','eventCategory': category,'eventAction':action,'eventLabel': ''});
} catch(err){}
 
setTimeout(function() {
document.location.href = link.href;
}, 100);
}

Sorry, the code is:

function trackOutboundLink(link, category, action) {
try {
dataLayer.push({'event':'interaction','eventCategory': category,'eventAction':action,'eventLabel': ''});
} catch(err){}
setTimeout(function() {
document.location.href = link.href;
}, 100);
}

It could be the method you’re using to redirect the user after the event trigger. Try replacing this line of code

document.location.href = link.href

to

window.location.href = link.href;

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.