DeveloperTutorials for Web Developers & DesignersForms

Add Contacts to Groups via Form Submissions

This tutorial will show you how to add a contact to a group as part of a form submission.

To add a contact to a group as part of a form submission, use the form attribute contactgroupadd="/insert-group-id-here/":

You will need to specify the ID of the group you'd like contacts added to. To find the group ID, go to Dashboard > Customers > Groups > Find the Group, click "Edit Properties".

Combobox to Select a Group

You can further customize this solution to allow the user to select a group from a combobox.

This approach is commonly used to help sort contacts into groups based on why they enquired.

The Combobox dropdown will populate with groups dynamically (eg. populate with all child groups of the group with id = '/what-can-we-help-with/').

To get started, setup a heirachy of groups via Dashboard > Customers > Groups:

Add a combobox to the form, where the options for the combobox populate dynamically with groups:

You will also need to add some additional attributes to the form:

Instead of defining a group ID, update the contactGroupAdd attribute, so that it uses the value of the combobox with ID=form_reason.

Here is the final solution: 

Checkboxes to Add to Multiple Groups

Taking the above example a step further, you can allow users to select multiple groups by employing checkboxes instead of a drop-down combobox:

To explain

The value of the checkboxes are grouped together in an array, which can be referenced by the name="" attribute used on the comboboxes. 

You can get the value of the array of comboboxes by using this function:

$lead_capture.getValueForFormItem('form_reason') = [];

Where $lead_capture is the form ID, and 'form_reason' is the name="" attribute of the comboboxes.

The contactgroupadd="" attribute of the form cannot accept an array, it needs group ID's separated by commas in a format like this: 


To achieve this, the PHP implode function is used to separate the group ID's by a comma character:

contactgroupadd="implode(',' , $lead_capture.getValueForFormItem('form_reason'))"