Passing a querystring variable to a hidden field


#1

Is there an easy way through Unbounce to pass the value of a querystring variable in the URL to a hidden field to be submitted with the form? I’ve done this in the past by setting a cookie that follows the user around as they navigate a site but never just pulling right from the querystring.

Any assistance would be greatly appreicated!


Passing Variable from Cookie to Lead Object/Form
#2

That’s fantastic! Thanks for the help and quick response.


#3

My pleasure!


#4

hi Carter,

I have an issue with passing inf_field_FirstName, all other variables are getting populated correctly except of that one and i can’t figure out why!

http://evolve.thecoachinginstitute.com.au/coaching-in-action/register/?inf_field_LastName=mark2&inf_field_FirstName=mauro&inf_field_Email=maria5%40email.com

thanks for your help

Mauro


#5

And if i wanted to place the hidden fieled in the javascript code for tracking what is the protocol to pull the information through and place in the tracking url

hidden field is aff_sub

ie script looks like this g/aff_l?offer_id=191&aff_sub= {aff_sub}

what do i use to populate aff_sub


#6

Hi Craig, as long as you have a hidden field (or visible field) with the same exact name as the query string in the URL, we will automatically populate the value of that field with the value of the query string. For example, a field in your form named first_name would capture the value of “Carter” if the user accesses your page from the url: yoursite.com/pagename?first_name=Carter

Hope that helps!


#7

@Carter can you please show us the working script code for this.


#8

Hi Mlnfx,

No scripting required! See the following screenshot where I have added a hidden field with name/ID of “first_name” to my form.


#9

We are using a dynamic refferal from another platform, what we are trying to achieve:

getting a part of the string from the url passed as Refferal column, In order for that we had a thought maybe to do a work around something like this:

document.getElementById(‘referralcx’).value = window.location.href.split(’?’)[1];

But the value of the hidden field is not chaning.


Form Field ID for Custom Script
#10

related: Form Field ID for Custom Script