Solved! Go to Solution.
Hi,
I have used this code in Marketo Landing Page. It capture's the UTM parameters and carries to next page successfully.
Their is one challenge with this code. In my Landing Page, I have a Tel Link <a href="tel: + 56-3121-9090">Call + 5-3121-9090</a>
The code also puts UTM after this Telephone Link.
How can I ignore this link?
Regards
Raj
That code is far too verbose for this task, in addition to being buggy.
Switch to this (it has zero dependencies on other scripts):
(function(){
const arrayify = getSelection.call.bind([].slice);
const appendableSearch = document.location.search.substring(1);
if(appendableSearch){
arrayify(document.links)
.filter(function(link){
return /https?/.test(link.protocol) && !/^#/.test(link.getAttribute("href"));
})
.forEach(function(httpLink){
httpLink.search += (httpLink.search ? "&" : "") + appendableSearch;
});
}
})();
By filtering non-http(s) links and local jump links, it ensures only http links will be decorated.