The ‘IfElement’ action allows you to handle multiple scenarios on your user journey. It is very similar to the ‘IfAssert’ but alot more equipped to deal with several scenarios rather than just two. This is particularly useful if you have active A/B testing on your site. You can easily add new scenarios as they are implemented.
To add an ‘IfElement’ first identify exactly where the elements change. It is also helpful to take note if there is a more likely scenario that the journey will reach. This will be the first element the script checks for.
Enter in the condition, selector and a comment which will set the first scenario to check. The Timeout is how long the journey will check before moving on to the next condition. We recommend keeping this to the standard 5 seconds. If you have 5 scenarios each with a 5 second timeout it will take 20 seconds to reach the final scenario.
To add another condition click ‘Add ‘ELSE IF’ Condition’ and repeat the process.
Back in the script editor you will now see the boxes which will house the actions for each scenario. You will notice that there is an extra box called ‘Else (All “if” Statements Return False), this is the scenario if everything else returns false. We would recommend using this for the least likely scenario/condition to reduce journey times.
Here is an example of the ‘IfElement’ in action. You can see three scenarios each expecting a different button for selecting a product. The following ‘WaitForElement’ assumes that the following page is the same no matter the scenario however you could include more steps within the scenario sections or create another ‘IfElement’ to handle this.
If you have any questions or are struggling to implement the ‘IfElement’ in your journey feel free to contact support and we can help!