Skip to main content
All CollectionsAdvanced Features and FunctionalityPre-filled Forms
Automatic Data Capture with Javascript Variables
Automatic Data Capture with Javascript Variables

Pre-fill answers on a form or set reporting metadata with the Automatic Data Capture feature using values set via Javascript variables

Ashleigh Alldredge avatar
Written by Ashleigh Alldredge
Updated over a week ago

Step 1: Declaring the values via Javascript variables

In order for an embedded form to see the declared values, they must be declared as variables in the global scope of the same HTML page where the form is embedded.

They can be defined in line in the file:

<script> 
var foo = "abra";
var bar = "cadabra";
</script>

or within a referenced external Javascript file:

<script src="myjavascript.js"></script>

Step 2: Capturing the values from Javascript:

The GiveGab Enterprise form will need to be configured to capture the values within the Administrative Control Panel. To get started, go to the specific form’s Form Details screen and click the Edit icon in the upper right of the Automatic Data Capture section.

First, add a 'Question Answer' based rule for each of your defined Javascript variables as a Source Variable and select the desired On Success behavior for each:

  • Selecting Question Answer indicates that the value of the declared Source Variable will be used as the answer to a specific question on the form. You can identify the specific question to be pre-filled in the adjacent menu.

  • Also, when Question Answer is selected you can optionally change the behavior of the form widget when the particular question is successfully pre-filled with a value (‘On Success’):

No action

This will add the captured value into a text input for text questions. For ‘Yes/No’ & ‘Multiple Choice Single Response’ question types, if the captured value matches an existing choice it will be selected. This is the default setting.

Hide Question

This will remove the question label and input from the form widget before it is displayed to end users.

Show as read only

This will display the question label and captured value as text only. No form inputs will be displayed.

Selecting Reporting Metadata as the desired fill behavior indicates that the values should be passed with every form submission in addition to the user’s question answers. Each metadata item can be added as a columns in report results.

Including values captured as ‘Reporting Metadata’ in a 'Form Answers' or 'Financial Transactions' report:

To include the value of the parameters captured with each form submission as a separate columns in a Form Answers or Financial Transactions report, use the configuration below when adding a new column:

  • Select Advanced Data Fields as the category

  • Select Snippet Metadata as the column

  • Enter the specific key name used when creating the Automatic Data Capture rule as the Metadata Key

  • Optionally, you can include a custom Column Header

Finally, remember to click ‘Save’ when done configuring the column as well as save all changes to your report.

Did this answer your question?