Advanced tour steps can run custom JavaScript from a next-button action. Use this when the tour needs to open a menu, trigger a product state, or prepare the.
A product tour's primary button can run trusted JavaScript before its normal next, complete, link, or widget action. Use this to prepare product state for the next step.
Configure the action
- Edit the tour step in the in-app builder.
- Open Behaviour > Actions.
- Open Primary button settings using the gear control.
- Choose Run JavaScript and enter the code.
- Preview the step in a safe environment before publishing.
Runtime behavior
The code runs before the primary button's configured action and can access window, document, step, button, and event. Async code is supported. Returning false or throwing an error prevents the remaining button action and stops tour progression.
Limits
- This applies only to the primary button, not previous or close controls.
- It is not a general tour lifecycle hook.
- Use only code you trust in your own product.
Troubleshooting
- Check the browser console when the action fails.
- If the next target is missing, wait for any asynchronous UI change before allowing progression.