How to Capture the Submission Date and Time in a Hidden Field

Follow

Unbounce records the date and time of every form submission. You can see it in the Leads table and in CSV exports, but it isn't included as a field in lead notification emails. This script writes the current date and time to a hidden field so it's included with the rest of the form data.

This is community code, not an official Unbounce feature. Unbounce Support can't troubleshoot custom code. Test it on a published page before relying on it.

Add the script to your page

  1. Add a hidden field to your form. This example uses the field name Date_Submitted.
  2. In the JavaScripts section, add the following script with placement set to Before Body End Tag. If your hidden field has a different name, update it in the script. It must match exactly, including capitalization and underscores.
<script>
// Change the word Date_Submitted in the following line to the name of your hidden field label.
// It has to match exact label, including capitals, underscore, etc...
var inpElm = document.getElementById('Date_Submitted');
var d = new Date();
var pD = d;
window.setTimeout(sD, 5000);
window.setInterval(sD, 30000);
function sD(){
inpElm.value = d;
}
sD();
</script>
  1. Save and republish the page.