Dynamic text update in page with URL parameters in Unbounce

In this digital marketing era, we want to make our landing pages and websites to be as personalized as possible to make it user friendly. This is where, URL parameter gets in, that we use to forward the values of user submissions from one page to another so we could autofill the web forms on next page or create sessions for users.

 

But sometimes, many of us have very simple requirement of showing the user submitted data on the thank you page or on the next page to personalize their experience.

 

For e.g. if someone filled an optin form on your landing page and filled their name in the “Name” field. You may want to show their name on the thank you page to personalize their experience. 

 

We all want to do it but it doesn’t count in part of plan, as it looks very difficult to do.

But not anymore. Let’s see how to do it. 

 

NOTE: Below solution can be used in your custom website and other CMS as well. We have seen more requests in Unbounce regarding this. 

 

So the tutorial is specially added to help users facing this problem in Unbounce.

Follow these steps to get values from URL

URL parameters (also called query string parameters or URL variables) are used to send small amounts of data from page to page, or from client to server via a URL.

 

They can contain all kinds of useful information, such as search queries, link referrals, product information, user preferences, and more. In modern browsers, this has become a lot easier, thanks to the URLSearchParams interface. 

 

This defines a host of utility methods to work with the query string of a URL. Assuming that our URL is https://example.com/?email=abc@xyz.com, we can grab the query string using window.location.search: Follow the steps here to add it in your page:

 

  1. It’s important to transfer the form data to next page with parameters. So you need to go to the form page and check the option “Append form data to URL“. This will transfer the values to next page where you want to update the text dynamically. This option is available when you select the form element in your page.
Append form URL unbouncehacks

2.  Add the custom HTML element in your next page and add the following code in your HTML block.

				
					<p>Your static text <span id="email">Dynamic Content</span> static text continues.</p>
				
			

In this example, “email” is the ID used with <span> tag.

 

3. Write the following javascript in your page javascript section.

				
					
const queryString = window.location.search;console.log(queryString); // ?email=abc@xyz.comconst urlParams = new URLSearchParams(queryString);const email = urlParams.get('email')
console.log(email);
document.getElementById('address').innerHTML = email;
				
			

 

4. In above code, const email = urlParams.get(’email’) you can update the “email” with the parameter name you need the value for.

 

Let’s say you want to get the name value from the parameter, so you can update it like const email = urlParams.get(‘name’).You can keep the remaining code as it is.That’s it!

 

Now you should submit, your form and check the next page to see if the value is dynamically updated in the page.

Let me know if you face any issues while implementing in the comment section. I will be happy to help.

 

Subscribe to get notification about new hacks and tips I come up with.

Leave a Reply

Your email address will not be published. Required fields are marked *

Sahibjot Singh

Sahibjot Singh

Hey there! I'm Sahibjot Singh, and I've been on an exciting journey as a Web Designer/Developer and Email Automation expert for the past 12 years. It's been a fantastic ride filled with new challenges, and I've learned how to overcome various issues along the way.

One thing that's always been a part of my journey is the need to research and gather different puzzle pieces, using my coding knowledge to piece together solutions for a wide range of problems.

But here's the thing: I've realized that there are many business entrepreneurs and non-technical folks out there who don't have coding skills but often find themselves in similar situations.

So, what makes Unbouncehacks/Unbouncetips special? Well, it's not just a collection of scattered information. I've put together complete end-to-end solutions for the very problems I've encountered and that you might face in the future.

Plus, I keep this website updated with fresh tips and suggestions that have helped me excel in design and email marketing over the years. So, you're in for a treat with a treasure trove of knowledge! 🚀

Share:

Facebook
LinkedIn
Twitter
Skype
WhatsApp

Most Popular

Follow Us

Categories

Doing the best for email marketing? Still your domain can be black listed if you hit a spam trap, once.


Verify your contacts for FREE and make sure there are no spam traps or invalid emails. 

― Receive the latest articles
Subscribe To Our Newsletter

Get notified about new articles