We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Nov 24, 2021 6:43 AM - edited Nov 29, 2021 7:43 AM
I am using this script to pass data from a form into a URL
Problem: the email is passed encoded and a %40 is added instead of the @
I need the full email because I use it then to populate a hidden field in a Typeform form.
Thanks a lot for your help 🙂 Site
<!--[if lte IE 8]> <script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script> <![endif]--> <script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script> <script> hbspt.forms.create({ portalId: "[PORTAL ID]", formId: "[FORM ID]" }); // add custom script after it var array = []; window.addEventListener('message', event => { // in the onFormSubmit global form event, grab the data and push it to the above array if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') { let vars = ['firstname', 'lastname', 'email', 'phone', 'hs_language']; let len = vars.length; for (i = 0; i < len; i++) { for (j in event.data.data) { if (event.data.data[j]["name"] == vars[i]) { let object = { name: '', value: '' }; object.name = vars[i]; object.value = event.data.data[j]["value"]; array.push(object); } } } } // after the form has submitted and data sent to Hubspot, get the data from the array and then redirect the page, adding the data to the URL if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') { var firstname = array[0].value var lastname = array[1].value var email = array[2].value var phone = array[3].value var lang = array[4].value window.location = "[URL TO REDIRECT TO HERE]?firstName=" + encodeURIComponent( firstname ) +"&lastName=" + encodeURIComponent( lastname ) +"&email=" + encodeURIComponent( email ) + "&phone=" + encodeURIComponent( phone ) + "&language=" + encodeURIComponent( lang ); } }); </script>
Nov 24, 2021 11:13 AM
@tjoyce , maybe you can help out here?