Skip to content
Advanced

Custom Events

GuideSail emits browser CustomEvents on window throughout the guide lifecycle. Use these to react to guide activity — for example, tracking completions in your analytics, showing UI elements after a guide ends, or syncing state with your app.

Events fire for both automatic and manual guides.


guideStarted

Fired when a guide begins.

js
window.addEventListener('guideStarted', (e) => {
  console.log(e.detail)
})
PropertyTypeDescription
guideIdstringID of the guide that started
titlestringTitle of the guide
stepCountnumberTotal number of steps
trigger'automatic' | 'manual'How the guide was launched
timestampnumberUnix timestamp of when it started

guideStepChanged

Fired each time the user advances to a new step.

js
window.addEventListener('guideStepChanged', (e) => {
  console.log(e.detail)
})
PropertyTypeDescription
guideIdstringID of the active guide
stepIndexnumberZero-based index of the current step
stepCountnumberTotal number of steps

guideEnded

Fired when a guide is completed or dismissed.

js
window.addEventListener('guideEnded', (e) => {
  console.log(e.detail)
})
PropertyTypeDescription
guideIdstringID of the guide that ended
completedStepsnumberNumber of steps the user reached before ending

Example — track completion in your analytics

js
window.addEventListener('guideEnded', (e) => {
  const { guideId, completedSteps } = e.detail

  myAnalytics.track('Guide Ended', {
    guideId,
    completedSteps,
  })
})

Example — show a follow-up prompt after a guide finishes

js
window.addEventListener('guideEnded', (e) => {
  if (e.detail.guideId === 'YOUR_GUIDE_ID') {
    document.querySelector('#followup-banner').style.display = 'block'
  }
})