Using conditional logic and validation for forms

Get ready to level up your Forms! We'll show you how to add conditional logic to make your forms smarter, implement validation to ensure accurate data, and seamlessly create attributes in the Hub for better data organization. Let's take a look!

Adding conditional logic

To add conditional logic to your form, select LOGIC & VALIDATION in the bottom right-hand corner of your question block.

Questions with Condition Logic can't be required
If a question has a conditional logic rule, it cannot be required. Trigger questions can be required.

"Conditional logic" lets you add rules that change whether a question is seen by the responder, or hidden from display, based on the answer to a "trigger question" earlier in the form. For example, you could hide one or more questions related to in-store experience, if the respond answered an earlier question to say that they shopped online.

Let’s take a look at some more examples in the Forms. 

We’ll start simple, our first example shows an NPS survey. The user will indicate on the 0-10 scale how likely they are to recommend Fitness Co to someone. 

Let’s assume you'd like to add a follow up question to ask for more information, but you want the user to see a different question depending on the score they give. This is where conditional logic really shines. 

There are two potential outcomes with the conditional logic we have set up:

  1. If they select equal to or less than 5, “We're sorry to hear that you had a negative experience. What could we do to improve?” will be visible. 
  2. If they select equal to or greater than 6, “We're so happy to hear you've had a positive experience. Could you tell us where we could improve?” will be visible. 

The outcome, one question will be hidden and the other visible depending on the score given. If the user rated their likelihood to recommend Fitness Co a 7, they would only see the “We're so happy to hear you've had a positive experience. Could you tell us where we could improve?” question. 

Let’s take a look at another example. 

This example is attempting to collect specific product feedback to inform future design decisions. You can see the parent question “What was your more recent purchase? pick a category”. Based on the selection, questions will be hidden or visible. If they select “Tops” for example the user will see a question asking for feedback on the Top they purchased, all other questions have been hidden. 

There are a multitude of ways you can utilise conditional logic in forms to create wonderfully simple user journeys through a survey. Get creative and if you are having trouble please reach out to your Success Manager or support@lexer.io.

Adding validation

To add validation to your form, again, select LOGIC & VALIDATION in the bottom right-hand corner of your question block.

Validation allows you to set rules around what kind of inputs will be accepted by your form. For example, the email address field requires answers to contain @ and .com before the answer will be accepted. If the answer doesn’t contain these validators then an error message will appear.

Lexer tip!
You can create custom error messages for your forms, or use the default set by Lexer.

Associated attribute

As well as logic and validation, you’ll also find the Associated Attribute section here.

What this section displays is either the new attribute that will be created from this question, or the standard attribute that the data from this question will flow in to. You will then be able to access this attribute in your Hub.

For example, you could create a multiple choice question that asks “What’s your favorite ice cream flavor from our new range?” The Associated Attribute would then be What’s your favourite ice cream flavour from our new range? and you would find this attribute and the associated data in Segment.

Lexer tip!
There are some exceptions to this, for example “Address”. If a responder answers three separate questions: Street Name / City / Country, then you would have three associated attributes. One for Street Name, one for City, and one for Country. Email is another exception, the Associated Attribute would just be Lexer’s standard “Email” attribute even if the question is phrased differently, for example, “What is your email address?”

What's next?

Lexer’s Form Builder is the ultimate way to create forms and surveys to capture zero-party data directly from your customers. To learn more about access and pricing, you can find more detail here. If you would like any help, reach out via the chatbot in the bottom right hand side of the page. We have heaps more content that showcases Lexer's Form Builder. You can see the full list of Forms content here.

Updated:
June 2, 2024
Did this page help you?
Thank you! Your feedback has been received!
Oops! Something went wrong while submitting the form, for assistance please contact support@lexer.io