JavaScript to pass utm parameters from url to button
Good Day
Can i use the custom JavaScript in the footer to pass the utm parameters from URL to the button?
<script>
//get utm to link
const urlParams = window.location.search;
document.querySelectorAll('a')
const href = el.getAttribute('href').
if (href.indexOf('#') === -1) {
const updatedHref = href.includes('?')
? href + urlParams.replace('?', '&')
: href + urlParams;
el.setAttribute('href', updatedHref);
}
});
</script>
This is the code i want to use
-
Hi Kenny,
Thank you for reaching out to us.
Upon checking, it appears that it was originally intended to add UTM parameters to a link, rather than a button. Additionally, please note that this script may not be work in Brizy.
To address this, I would recommend reaching out to your developer and requesting an update to the script. Specifically, ask them to modify it to target a class assigned to a button and append the UTM parameters accordingly.If you have any further questions, please let us know.
Best regards,
Ariel H.0
Please sign in to leave a comment.
Comments
1 comment