Advice and answers from the UserGuiding Team
Users
Engagement
Settings
Triggering a Guide via JavaScript
You can invoke a Guide programmatically by using JavaScript.

You can easily trigger a Guide using the following method from our JavaScript API.


userGuiding.previewGuide(guideId)

 

You can find the guideId  on your Guide settings, under the Guide's title.



In the example below, we're triggering a Guide through an HTML button.


<button onclick="window.userGuiding.previewGuide(guideId)">Play my Guide!</button>


If you want the Guide to be triggered only if the targeting conditions are met, set checkHistory as false. If true, it tries to meet the targeting and segmentation conditions. The default value is false.


userGuiding.previewGuide(guideId, { 
  checkHistory: true,
})


Finally, you can also start a Guide from a specific step. The default value is 0 (first step).


userGuiding.previewGuide(guideId, { 
  initialStep: 2,
})