Pass variables like URL, Google Client ID, etc. to hidden field


Hey there!

I want to track the URL from where a form was submitted via a hidden field.
How can I dynamically insert that value in Unbounce?

Is there a function for that?

I know that I can use URL parameters but I would need dynamic values like Google Client ID, URLs, etc.

Any ideas or solutions for that?

Thanks in advance


Hey @SebastianTh,

If it’s available on the page, you will have to write a small JS script that would capture the required value and fill in your hidden fields.

It really depends on the particulars and what you are trying to record.



I wanted to track the Lead Source from our Forms which when filled out, would post these in Zoho so I could run reports on successful campaigns etc. I just created a Lead Source field in my Zoho Lead page, and then in Unbounce added a hidden field with the Value (name of Lead Source… such and such Landing page) and then mapped it in the Unbounce integration area. Easy peasy. That said I was unable to take it another level and and map the refferer (ie. Google Ad). That’s next on my list to figure out.

Good luck!



Would a tool like Google Analytics help you out here? Implement GA on the site, setup the form submit as a goal and you’ll have the source/medium for every goal in GA.

If you really want to send that data via e.g. a hidden field with the form submit itself I guess you’ll have to use the ‘document.referrer’ within a local JavaScript and store the data. The ‘document.referrer’ will not make a difference between organic or paid traffic from e.g. Google, it will all seem to originate from ‘’. You could have logic within your JS that e.g. looks if there is a query string parameter of ‘gclid’ and if that’s the case you know it’s from a paid ad. Same goes with ‘utm_campaign’ parameters if needed.



Okay folks I solved my issue in the meantime and thought I would share that with you:

The function retrieves the Information of GA Client ID from the cookie and passes it on into the Hidden Field. It does the same with the URL:

<script type="text/javascript">
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
  var c = ca[i];
  while (c.charAt(0)==' ') c = c.substring(1,c.length);
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
return null;
document.addEventListener("DOMContentLoaded", function(event) {
var gclid = null;
var gclid_count = 0;
gclid_int = setInterval(function(){
  gclid = getCookie('_ga');
  if(gclid != null || gclid_count>50) {
    document.getElementById("form_gclid").value = gclid; // Writing into the hidden field

var domain = + window.location.pathname;
document.getElementById("form_domain").value = domain;

You can either implement it via GTM or with the Script Manager in Unbounce.