Branch a Tour Based Based on Survey Responses
This recipe shows you how to branch a tour based on a survey response. This can be useful when you want a tour to go in different directions depending on how a user answers a survey question. In this example, you'll create a survey that asks users their role, then branch a tour based on their response.
Instructions
- Within Guides and Surveys, navigate to Content. Under Surveys, click + Add survey.
-
In the settings for the survey, configure:
- Survey Name: User Role Survey.
-
Where to show this survey?: Choose Only certain pages and user segments and set URL contains to
test-user-role-survey.
Note: For the purposes of this demo recipe, the survey is set to show only on pages with
test-user-role-surveyin the URL. Set this to the URL of the page where you want to show the survey once you've published it. - Under the survey's First page, click Add element and choose Choice (Radio).
-
Under Question Settings, configure:
- Question: What is your role?
- Choices: Engineer, Product Manager, Designer, Other.
Now that the survey is set up, we'll publish it and get the question_ value from the developer console.
- Click Publish from within the survey editor and run the survey on a page of your choosing.
-
Navigate to a page with Guides and Surveys enabled and add
?q=test-user-role-surveyto the URL to trigger the survey to appear. - Select Engineer from the choices and click Submit.
- Open the developer console in your browser.
-
In the JavaScript console, type
window.usetifulTagsand press Enter. You should see aquestion_key-value pair that matches the choice you selected.Notes:
- The
question_value is an integer that matches the 1-based index of the choice you selected. Since Engineer was the first choice in the list, itsquestion_value is1. - To reset the survey during testing, go to Application > Storage in your developer console and click Clear site data.
- The
-
Copy the
question_value and save it for later use when you create the tour.
Now that you have the question_ value, create the tour and use it to branch the tour based on the user's response to the survey.
- Within Guides and Surveys, navigate to Content. Under Tours, click + Add tour.
-
In the settings for the tour, configure:
- Tour Name: Product Tour [Start].
-
Where to show this tour?: Choose Only certain pages and user segments and set URL contains to
product-tour-start.
Note: For the purposes of this demo recipe, the tour is set to show only on pages with
product-tour-startin the URL. Set this to the URL of the page where you want to show the tour once you've published it. - Under Tour Flow, click + Add Step and choose Condition. You'll configure this step in a later step below.
- Under Tour Flow, click + Add Step and choose Modal, and set the Title to Engineer Product Tour.
- Under Tour Flow, click the gear icon next to the Condition step you added earlier and set its Title to Engineer Condition.
-
Under IF, configure:
- Set the dropdown to Tag value.
-
In the Tag name text box, enter the
question_value you saved earlier. - Choose is for the next dropdown.
-
Set the Tag value to
1to match Engineer, since it was the first choice in the survey.
-
Under THEN, set the dropdown to Go to step and set the tour step dropdown to Engineer Product Tour.
Note: You can also choose Another tour here if you prefer to use an entirely separate tour for each role.
- Under ELSE, choose Close tour.
- Click Publish from within the tour editor and run the tour on a page of your choosing.
-
Navigate to a page with Guides and Surveys enabled and add
?q=product-tour-startto the URL to trigger the tour to appear. - Confirm that the tour starts and the Engineer Product Tour modal appears.
- Close the modal to confirm the tour ends.
Relevant Help articles: