Question

Track several checkbox values on form submit

  • 19 April 2024
  • 1 reply
  • 22 views

Hi there!

What’s the best way to track several checkbox values once we submit a form or trigger a custom event for the submission?

Essentially we get a list of values of all the selected options and we’re want to see all those listed or grouped. We tried adding the values as custom event properties but we can only group by a max of 4 properties, and we might get more than just 4 values per event.

Any help and recommendations are appreciated ~


1 reply

Badge

Hi

To manage your webpage checkboxes and collect their values when a submit button is clicked, start by identifying all checkboxes and the submit button on your page. Using JavaScript Snapshot, as detailed in Heap's documentation here, set up an event capture on the submit button to detect when it is clicked. This will trigger the action you want to perform with the selected checkbox values

Once the button is clicked, begin looping through each checkbox in your form. Check if each checkbox is selected during this loop. If a checkbox is checked, add its value—usually the label or text next to the checkbox—to a list of selected options.

This method ensures that you accurately capture and can utilize all selected options from the checkboxes once the submit button is activated, facilitating further processing or display of these selections.

Reply