Use if/then branches in workflows

Last updated: July 12, 2019

Applies to:

Marketing Hub  Professional, Enterprise
Sales Hub  Professional, Enterprise
Service Hub  Professional, Enterprise

Use if/then branches in workflows to direct enrolled objects down one path or another based on set conditions.

Add an if/then branch

  • Click the plus icon +. add-an-action
  • In the right panel, select Add if/then branch.
  • Select the criteria for the if/then branch. If/then branch criteria options are identical to enrollment trigger criteria options.
  • When you're done, click Save.

Please note: if your branch criteria is based on a contact or associated contact engaging with content in a previous action in the workflow (e.g., contacts opening a marketing email sent in a previous action), add a delay before your branch to ensure that they have time to engage with your content.

  • Click the plus icon + to add an action under the YES branch or under the NO branch. In the example below, if a contact has filled out the Contact Us form, they will go down the YES path. If they have not filled out the Contact Us form, they will go down the NO path.if-then-branch-example
  • Click the plus icon + to add more actions if needed.

Please note: In contact-based workflows, you can add up to 19 if/then branch levels in a workflow. When you attempt to add more than 10 if/then branches, you'll see a warning message recommending you to streamline your workflow by enrolling contacts into another workflow. In company, deal, quote, and ticket-based workflows, you can have more than 19 branch levels, but you may see degraded performance.


Test branching logic

Contact-based workflows

In contact-based workflows, the Test feature will enroll the record and all workflow steps will execute immediately. Therefore, if you set up a workflow with an if/then branch that depends on a record's action from a previous step, there will not be enough time for the test object to take action before they reach the if/then branch.

To test if/then branches in your contact-based workflow, add shorter delays to the workflow, then manually enroll a test object:

  • In your HubSpot account, navigate to Automation > Workflows.
  • Click the name of a workflow.
  • In the workflow editor, select a delay.
  • In the right panel, set each delay in your workflow to a few minutes. There should be enough time for the object to take action before reaching the if/then branch. test-branching-logic-shortened-delay
  • Once you've edited your delays, click Review, then click Activate to turn on your workflow.
  • Manually enroll your test object.
  • Make sure that your test record meets the criteria of your if/then branches. For example, if the if/then branch criteria depends on a contact or associated contact having opened an email, make sure to open the email before the delay is over.
To test both branches, create and enroll two test objects, one which meets the criteria of your if/then branch, and one which does not. Alternatively, you can enable re-enrollment and manually enroll your original test object again, this time making sure they do not meet the branch criteria.
When your testing is complete, make sure to reset your delays to the correct amount of time before turning the workflow on.

Company, deal, ticket, and quote-based workflows

In company, deal, ticket, and quote-based workflows, the Test feature will not execute any actions in the workflow, but instead will indicate whether or not the tested record meets the enrollment criteria, and show the simulated outcome and timestamp of each action. For each if/then branch, you will see if the record would follow the yes or no branch, and you can preview other possible branch outcomes. Learn more about testing these workflow types