Variables are like boxes that can hold a piece of information within your form, such as a number or word. You can combine variables with branching rules to change the value of a variable based on how respondents answer your form. You can then map variables to your Typeform Contact profiles to create segmented lists and send targeted email campaigns.
In this article, we’ll walk you through how to:
- Create a custom Contact property
- Build your form and add a custom variable
- Change the value of a variable with branching rules
- Map a variable to the custom Contact property
We’ll use an example of a hair care company that is collecting leads from a form. The form will determine a respondent’s hair type based on how they answer a few questions. We’ll then store the respondent’s hair type as a Text variable. Once a lead is collected, we want to add them to our Contacts database in Typeform and map their hair type to their Contact profile.
Create a custom Contact property
First, we'll create a custom Contact property where you can map a variable to. We’ll create the custom Contact property Hair type in our Contacts database.
- Click on the Contacts tab from your Workspace.
2. Click + Add property and either click to add a predefined standard property or scroll down to + Add custom property.
3. If you choose to add a customer property, enter your property name. We’ll type in Hair type and click Save.
Build your form and add a custom variable
- To create a Contact in Typeform, you’ll need to ask respondents for their email address. You can use either the Email or the Contact Info question type.
2. We’ve added a few Multiple Choice questions to determine a respondent’s hair type.
3. Lastly, we added a Yes/No question to ask if they consent to receiving emails from us. This is a required question as you’ll need to map a respondent’s subscription status when adding them as a contact.
4. Next, we’ll add a custom variable to our form. Click the Workflow tab.
5. Click the Variables icon (x).
6. Click + Add custom variable.
7. Type in the variable name you want to use and in the dropdown select if you want to use a number or text variable. We’ve added a hair_type text variable. Click Save when you’re done.
Note! Only lowercase letters, numbers, and underscores are accepted when creating a custom variable.
Add Branching rules to change the value of the variable
In our example, we have two questions that will determine a respondent’s hair type: Dry, Normal, or Oily. We’ll add some branching rules on the last question to change the value of the hair_type variable that we just created in the previous section of this article.
- In the Workflow panel, click Branching.
2. Scroll down to the last question in your form and click + Add rule.
3. Click the dropdowns to create a rule. We’ll create a rule to say:
If question 2 How would you describe your hair after a typical wash?
Is the answer option Feels stripped or dry.
4. Since we have another question that determines the hair_type variable, we’ll need to add a condition to include the other question to the Branching rules. Click + Add condition.
We’ll select the and operator and create the rule:
And Question 3 What is your top haircare goal?
Is the answer option Restore moisture and repair damage.
5. Next to Then, is where we can change the value of the variable. We’ll click the dropdowns to create the action of the rule:
Then Replace (x) hair_type = Dry
We typed in the word Dry for the variable but you can enter in any word you like.
This will create the rule that if someone answers question 2 with Feels stripped or dry and answers question 3 with Restore moisture and repair damage, then this will replace the hair_type variable with the word Dry.
6. We’ll click + Add rule and repeat the step above to create more rules for the other hair_types, Normal and Oily.
7. Click Save when you’re done creating your Branching rules.
8. When you’re happy with your form, click the Share or Publish edits button to make your form live.
Map a variable to the custom Contact property
- In your Workflow tab, click the settings icon under Contacts in the right side menu.
2. Click + Map to property to map your form questions and variables to your Contacts database. The email question is automatically mapped for you.
3. We’ve mapped our form questions first name and last name and our variable hair_type. Click Save when you’re done mapping.
4. Next, decide how you would like to map the subscription status of the contact. You can either map the subscription status from your form’s question, or use a default subscription status.
We’ll toggle on Map to form question.
Then in the dropdown, select the question that asks respondents for their consent and map the answer options to the subscription statuses. Then click Save.
5. Decide if you would like to update current contacts with the mappings you’ve just created. If existing contacts aren’t updated, property mappings will only apply to contacts from new form responses.
Click Save when you’re done.
Now when someone fills out our form, their response will create a contact in our Contacts database and their hair type will be mapped to the Hair type contact property.
More ways to work with your Contacts
Now that you’ve created Contacts in your Contacts database, discover the various ways you can organize, manage, and use them.
- Create different contact lists based on the Hair type property.
- Filter your contacts based on Hair type and create contact lists.
- Sort and manage columns in your contacts table.
-
Create an automation to send an email when a contact property has been updated with dry hair.