Instantly share code, notes, and snippets.

What would you like to do?
Unbounce Community :: Tips & Scripts :: Dynamic Image Replacement Using URL Parameters
Do not remove this section. It helps our team track useage of external workarounds.
// Add the image source as the value of a URL parameter to have it appear on the page
// Add ID's of Images in builder
var imageOne = $("#lp-pom-image-11");
var imageTwo = $("#lp-pom-image-12");
// Add URL parameters
var img1 = getURLParameter('img1');
var img2 = getURLParameter('img2');
// function to get URL parameter
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(||[,""])[1].replace(/\+/g, '%20'))||null
// change image if parameter exists
if (img1) {
if (img2) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment