Skip to main content
Calculations (formulas)

Add calculations to your headline or text blocks with formulas.

Heyflow avatar
Written by Heyflow
Updated over a week ago

Add calculations to your flow by using variables to assign lead scores to your leads, or to tailor your sales process to each prospect. Whether you need custom offers or ROI calculators, create anything that delivers genuine value to your users.

The Calculation feature presents an excellent opportunity to offer your prospects a helpful tool, fostering increased trust in your brand — a proven method to boost conversion and lead rates.

❗This feature is not available on all plans. Take a look here to see if it’s included in your plan.


Setting up calculations

Generally, setting up calculation is pretty easy if you follow these steps:

  1. Highlight the text that you want to turn into a formula

  2. In the toolbar, select “Formula”

  3. Adjust the decimal places, fallback content and system label as needed

💡 Looking for more complex calculations? The entire math.js syntax is supported. If functions should be used, just omit the Math, i.e. Math.min(x,y) needs to be min(x,y) in Heyflow.

Calculations in responses & integrations

There's one thing to do, if you want to show flow visitors the results of your formula after they submitted their contact information but also want to see them in your response dashboard. Add the formula twice, once before and once after the submit event.

Also, when adding a system label you're able to see the results in your response and map them within our native integrations, such as HubSpot, Salesforce, or Airtable.

💡 Tip: If you want to show the calculation only in your response, but not to your flow visitors, simply hide the block under appearance.

Using variables in calculations

If you want to use prefilled content by the user to create a calculation, follow these steps:

  1. The information you want to add as a variable needs to be asked on a screen that comes before your calculation

  2. Use input fields that ask for a numeric value (you might want to consider using a mask to restrict the input to numbers only)

  3. (Set the respective input field as required to make sure the formula will have the necessary values to work with)

  4. Set the variable of the input field

  5. When setting up your formula, type "@variable" to use the respective input field's value in the calculation

💡 Multiple selection, like in multiple choice and picture choice, will result in an addition of the variables, e.g. if your options are 1,2,3,4 and the user selects option 2 & 4, in the calculation it results as a value of 6.

This does not affect the variable replacement in the text.

❗ If you're working with variables, you have to ask for all inputs previous to the calculation screen. At the moment, it doesn't work on one the same screen and would show an error message to the user.

Simple Navigation Logic with Inputs

We can use formulas and calculations to create navigation similar to conditional logic with buttons. However, instead of only considering the current page selection, we can evaluate all the user’s responses from several pages and direct them to a target page based on the result.

To make this work, it’s important that the variables are numerical. The following blocks are suitable for this: Picture Choice, Multiple Choice, Select, Slider and the Input Field (set to numbers).

Take a look at the example below on how to redirect logic based on an Input range.

❗This only works in a standalone flow, not in an embedded flow, because we’re using the flow’s URL for the redirection.


Examples

Lead Scoring

You can add calculations to your flow to assign lead scores to your leads by previous inputs, even if they are not numeric, and send them to your integrations for your team to prioritize their leads better.

If you want to give a score to a not numeric input, simply add the value in the system label for each of the options. If you then use that variable, the text gets ignored in the calculation and only the numeric input will be used for the calculation.

❗ In your response, the whole system label including the numeric input will show up, though.

Redirect Logic Based on an Input Range

We want to redirect users to a specific target page based on a value range. Instead of showing predefined options that might influence their choice, we use a simple input field instead of a multiple-choice block. In this example, we determine the redirection based on the user's age.

Step 1: Add an Input Field

  1. Insert an Input field at the desired place in the flow. Under General, set the input field to required.

  2. Under Labels & Variables set a variable (e.g. age).

  3. Under Decorators, ensure that the input accepts only number

Step 2 : Create the Calculation
On the next screen, add a Text block to process the input value. We want to redirect users as follows:

  • Age < 18 = Page 0

  • Age < 18-64 = Page 1

  • Age 65+ = Page 2

To achieve this, we use the variable from the input field (@age) in the following formula: @age < 18 ? 0 : (@age < 65 ? 1 : 2)

  1. Convert this formula into a Formula Block by selecting it and clicking "Formula."

  2. Name it something like “score”.

  3. Set decimal places to 0 to ensure a clean result. The text block will now display only the calculated result.

  4. Set this block's visibility to Hide to make it invisible for the users.

  5. Create a target page for each possible result and name them according to the outcomes used in the calculation (in our example, "0", "1", and "2").

Step 3: Redirect the User

  • Now, we use the score variable for navigation.

  • Add a screen with a Loader Block before your target pages and set it to "Redirect"

  • Use the flow URL and replace the part after # with @score

💡 You can also use a range slider instead of an input field. The setup is the same; just make sure to activate “Use numeric value” under “Labels & Variables” and use the corresponding variable.


Edit options

Option name

Description

Decimal places

How many decimal places should be shown in the results. At the moment, it's only possible to show max. 2 decimal places.

Fallback content

The message that will be shown to flow visitors if the calculation fails

System label

The field label that will be shown in the response dashboard

Did this answer your question?