How to append SOME form data to URL, but not ALL of it?


#1

Hello -

The analytics team here wants us to pass ONLY a hidden field we have in our form that is passing a unique number/identifier for each lead. They do not want to pass all the sensitive data like the name, email, address, etc, like it does if you check off ‘Append form data to URL’ :

http://example.com?first_name=Kyle&last_name=BishopBoathouse531c&email_address=kbishop531c%40boathouseinc.com&phone_number_optional=7816635313&street_address_name__number=260531c%20Charles%20Street&City=Waltham&zip_code=02453&Company=Company&utm_source=&utm_medium=&utm_content=&utm_campaign=&javascript_prepopulated_value=20170531133010032

They only want to pass the unique ID so the URL will look like this:
http://example.com?javascript_prepopulated_value=20170531133010032

Is this possible?

Thank you


#2

Hey @KRBishop,

One way you could achieve this is to add a web hook integration and use the URL Parameter Replacement feature.

In the example you’ve given, you’d configure a web hook with a URL like this:

http://example.com?javascript_prepopulated_value=(some_field_name)

When the lead is delivered to the web hook endpoint, the value contained in the field (in this case “some_field_name”) will be inserted into the URL.

URL Parameter Replacement works independently of the field map so you shouldn’t have to do anything with the field map (unless you want to map the values in the actual payload).


#3

This is kind of what our team is needed to do too. However the page it is navigating to is another unbounce page, and we want to know who the person is with their id, rather than using a cookie etc. at that is a bit overkill for what we need.

edit: I solved it writing this in a javascript at the end of the body:

data = “data to send through”;
window.module.lp.form.data.confirmData = window.module.lp.form.data.confirmData+data;

It does a quick append to the link that is already there in Unbounce’s code. You can use something to find any element’s data, and use this to add it to the lightbox link.


#4

Hi @veddit

I tried your solution but no luck unfortunately.

I put this into the Javascript pane, setting it to “before body end tag”

utm_source is the hidden field I’ve set up

Any ideas?

Thanks


#5

Hi @anthonybs, I can help out.

Could you copy and paste the code you put in to the JavaScript so I can check what is going on please.

I think I know what’s happening :slight_smile:


#6

Thanks @veddit. We made a few optimizations and it’s working nicely now:

   <script>
      
      document.addEventListener("DOMContentLoaded", function(){
      var data = document.getElementById("utm_source").value;
      window.module.lp.form.data.confirmData = window.module.lp.form.data.confirmData+data
    },false);

    </script>

#7

Brilliant. I’m glad to hear it :smile: