Skip to main content

Hey there!


I am trying to do the following:


I pass on the client’s phone number from Google Ads to the landingpage and have it dynamically replaced in buttons and text.


However I also want to keep the clickable links with the correct number.


How can I dynamically change the Click Action URL for buttons in Unbounce so that it not just shows the text correct but actually calls the right number, too?


Sebastian

Try using a variation of this:

 

<script>
document.addEventListener("DOMContentLoaded", function(e) {
const url_string = window.location.href;

// Change this to the URL of the target page
const base_url_string = 'www.your_base_link.com/';
// Change this to the Metadata ID of the button
const ui_element = 'lp-pom-button-111';

var url = new URL(url_string);
// Change my-param to the URL parameter you need
const myparam = url.searchParams.get("my-param");
document.getElementById(ui_element).href = `${base_url_string}${myparam}`;
})
</script>

 


Reply