jeudi 18 février 2021

How can I add the current url parameters to the href of an when clicking link to external site

we use instapage as a tool for landing pages and they strip url parameters from links if users click on tags with external links. I want to preserve the location.search though.

I tried using this script here, but it doesn't work at all - as in, the parameters still get removed unless they are specified in the href link.

window.addEventListener("click", function(e) {
    var href = e.target.getAttribute("href");
    if(href) {
        location.href = href + window.location.search;
        e.preventDefault();
    }
});​

Anything obvious I am missing here?




Aucun commentaire:

Enregistrer un commentaire