I am prohibited both by the policy in Google Analytics and by our own GDPR policy to pass the complete set of URL parameters from the main landing page to the formstep2 thank you page. I would like to capture just the first name from the formstep1 main LP. I am already using the progressive profiling script to pre-populate the first set of form fields to the next form step. Question, is there a way to populate a first name onto this second page using DKI but without grabbing it from the URL parameters? I can perhaps come up with a script but then need to have a means to actually pass that first name value to the page itself via DKI.
Did you find solution on this problem? I would like also to pass only 1 parameter to the TY page. Please comment if you find the solution. Thank you.
Yes, someone there at Unbounce or a contributor came up with a javascript that passes the form values in a session variable from the first page to the custom thank you page.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
// ##################
// UNBOUNCE AUTO FILL
// Do not remove this section; it allows our team to troubleshoot and track feature adoption.
// TS:0002-05-055
// ##################
ls_prepend = "UB_AF_";
retrieveFormData();
// On click of form button / on form submit, save all available data to local storage
$(".lp-pom-form .lp-pom-button").click(function(){
saveFormData();
});
function saveFormData() {
// save text fields
$(".lp-pom-form input[type='text']").each(function(i, obj) {
fieldValue = obj.value;
fieldID = obj.getAttribute("id");
localStorage[ls_prepend+fieldID] = fieldValue;
});
// save select fields
$(".lp-pom-form select").each(function(i, obj) {
fieldValue = obj.value;
fieldID = obj.getAttribute("id");
localStorage[ls_prepend+fieldID] = fieldValue;
});
// save checkbox fields
$(".lp-pom-form input[type='checkbox']").each(function(i, obj) {
fieldValue = obj.checked;
fieldID = obj.getAttribute("id");
localStorage[ls_prepend+fieldID] = fieldValue;
});
// save radio fields
$(".lp-pom-form input[type='radio']:checked").each(function(i, obj) {
fieldValue = "true";
fieldID = obj.getAttribute("id");
localStorage[ls_prepend+fieldID] = fieldValue;
});
$(".lp-pom-form input[type='radio']:not(:checked)").each(function(i, obj) {
fieldValue = "false";
fieldID = obj.getAttribute("id");
localStorage[ls_prepend+fieldID] = fieldValue;
});
}
function retrieveFormData() {
// look for and populate text fields
$(".lp-pom-form input[type='text']").each(function(i, obj) {
fieldID = obj.getAttribute("id");
fieldSavedValue = localStorage[ls_prepend+fieldID];
if(fieldSavedValue != undefined && fieldSavedValue != "" && fieldSavedValue != null) {
obj.value = fieldSavedValue;
}
});
// look for and populate select fields
$(".lp-pom-form select").each(function(i, obj) {
fieldID = obj.getAttribute("id");
fieldSavedValue = localStorage[ls_prepend+fieldID];
if(fieldSavedValue != undefined && fieldSavedValue != "" && fieldSavedValue != null) {
$(".lp-pom-form #" + fieldID + " option[value='" + fieldSavedValue + "']").attr('selected', true);
}
});
// look for and populate checkbox fields
$(".lp-pom-form input[type='checkbox']").each(function(i, obj) {
fieldID = obj.getAttribute("id");
fieldSavedValue = "";
fieldSavedValue = localStorage[ls_prepend+fieldID];
if(fieldSavedValue != undefined && fieldSavedValue != "" && fieldSavedValue != null && fieldSavedValue != "false") {
obj.checked = fieldSavedValue;
}
});
// look for and populate radio button fields
$(".lp-pom-form input[type='radio']").each(function(i, obj) {
// fieldValue = obj.value;
fieldID = obj.getAttribute("id");
fieldSavedValue = localStorage[ls_prepend+fieldID];
if(fieldSavedValue == true || fieldSavedValue == "true") {
$("#"+fieldID).prop('checked',true);
}
});
}
</script>
Thank you so much @Jim_Hill for the code. Appreciate it. We will try this code.
Make sure you have the script on both formstep1 and formstep2. Also be certain that if you want to pass for example the email that you have that field on the second form. Just copy that formstep1 CTA form to formstep2 then add any extra values you want to collect there.
Also, on the formstep2 page (custom thank you page after the first LP) put the form fields in order such that the ones you want to collect on formstep2 are on top. Then, size the form field object on the LP such that only those fields show.
Reply
Log in to the Unbounce Community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.