APIs & Integrations


Pass a non encoded string into a URL - Javascript

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 @

  • Any way to pass a non-encoded URL? I would like to pass the full email into the URL.

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>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
    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"];
    // 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 );


1 Reply 1
Community Manager
Community Manager

Pass a non encoded string into a URL - Javascript

@tjoyce , maybe you can help out here?



HubSpot Community Developer ShowMake sure to subscribe to our YouTube channel
where you can find the HubSpot Community Developer Show