Skip to main content

Tour

The tour methods allow you to start, navigate, and control tours programmatically. All methods are available on window.USETIFUL.tour after the usetiful:fullApiReady event has fired.

Tour IDs are numeric identifiers assigned in the Guides and Surveys dashboard when creating or editing a tour.


start(tourId, confirmation?, startStep?)

Starts a tour by its ID. By default, the tour begins at step 1 without a confirmation prompt.

When confirmation is true, the user sees a confirmation dialog before the tour begins. Use the startStep parameter to begin the tour at a specific step instead of the first one.

ParameterTypeRequiredDefault
tourIdnumberYes
confirmationbooleanNofalse
startStepnumberNo1

nextStep()

Advances to the next step of the currently running tour. If the tour is already on its last step, calling this method completes the tour.


preStep()

Returns to the previous step of the currently running tour. If the tour is on its first step, calling this method has no effect.


jumpTo(step)

Jumps to a specific step in the currently running tour. Steps are 1-indexed, matching the step numbers defined in the Guides and Surveys dashboard.

ParameterTypeRequired
stepnumberYes

close()

Closes the currently running tour. If no tour is active, this method has no effect.


getState()

Returns the state of all tours as an array of tour objects. Each object includes the tour's ID, name, current state, availability, and — when the tour is in progress — the current step number.

Returns: an array of tour objects with the following properties:

PropertyTypeDescription
idnumberThe tour ID
namestringThe tour name
statestringOne of 'never run', 'completed', 'inProgress', 'closed', or 'waiting'
isAvailablebooleanWhether the tour is available to start
currentStepnumberThe current step number (present only when state is 'inProgress')

getToursByElement(selector)

Returns an array of tours that are triggered by or assigned to a specific DOM element. The selector parameter accepts any valid CSS selector string.

Use this method to determine which tours are associated with a particular UI element, for example to build custom navigation or to conditionally display tour-related controls.

ParameterTypeRequired
selectorstringYes