JavaScript API
Tell Driver Studio who is signed in and what they do, start tours from your own code and listen to tour events. The same functions are on window.driverStudio and in the npm package.
On this page
Overview
driverStudio.identify('usr_4821', {
plan: 'pro',
signed_up_at: '2026-10-30',
})
driverStudio.track('report_created')
driverStudio.start('tour_8d1k2')
driverStudio.on('tour:completed', (event) => {
console.log('Finished', event.tourId)
})
// When someone signs out
driverStudio.reset()| Call | What it does |
|---|---|
identify(id, traits) | Says who this person is and adds details like plan or role. |
track(event) | Records something they did. Tours can start on it. |
start(tourId) | Starts a tour now, for example from your own help button. |
on(event, callback) | Runs your code when a tour event happens. |
reset() | Forgets the current person. Call it when they sign out. |
With the script tag, add the queue snippet from Install options so you can call these before the script loads. With npm, import them from @driver-studio/web.
identify
Call it after sign in with your own user id (up to 128 characters) and any traits you want to target on. Calling it again for the same person adds to their traits. Passing null as the id is the same as reset().
driverStudio.identify('usr_4821', { plan: 'pro', role: 'admin' })Traits power audiences. Up to 50 traits, names up to 40 characters, values up to 200 characters.
Traits are sent from the browser, so anyone could change them. Treat them as hints for choosing tours, not as proof of who someone is or what they paid for.
track
Starts any tour whose trigger is When your app sends an event with this name. Names use letters, numbers, _, ., : or -, up to 64 characters. You can pass a second argument with details, but only the name is used today.
driverStudio.track('report_created')start
Starts a tour published for this site, whatever its audience, page or trigger. It ignores the tour's How often rule, so a help button always works. Pass { force: false } to follow the rule.
driverStudio.start('tour_8d1k2')
// Only if How often allows it
driverStudio.start('tour_8d1k2', { force: false })On window.driverStudio, start returns a promise that resolves to true if the tour started. The tour id is in the dashboard address of the tour.
on and events
on returns a function that stops listening.
const off = driverStudio.on('step:shown', (event) => {
console.log(event.tourId, event.stepId, event.stepIndex)
})
off()| Event | When |
|---|---|
tour:started | A tour shows its first step. |
step:shown | Any step shows. |
tour:completed | Someone gets through the last step. |
tour:dismissed | Someone closes the tour before the end. |
Each event gets { tourId, stepId, stepIndex }. The short names started, completed and dismissed also work.
reset
Forgets the identified person on this browser. Call it when they sign out.
Extras on window
Once the script has loaded, window.driverStudio also has:
ready: a promise that resolves when tours for the page have loaded.tours(): the tours loaded for this site, as{ id, title }.refresh(): loads tours again.stop(): closes the tour that is showing.off(event, callback): stops a listener.
The window also gets a driver-studio:ready event when tours have loaded.