Concepts
Triggers
[object Object]
| Trigger | Starts when | Spec |
|---|---|---|
| First visit | The SDK runs for the first time for this user | { "type": "first_visit", "once": true } |
| Page or screen | A path (web) or route name (Flutter) matches | { "type": "page_view", "path": "/invoices/*", "once": true } |
| Event | Your app reports an event with track | { "type": "event", "name": "invoice_page_opened", "once": true } |
| After another guide | Someone closes the finish card of another guide (SDK 0.10+) | { "type": "guide_completed", "guide": "create-first-invoice", "once": true } |
| Manual | Your code calls start, or the user picks it in the launcher | { "type": "manual" } |
once (default true) means the guide starts at most once per user. A user can always replay it from the launcher, start() always starts it, and resetProgress() lets it start on its own again. In the builder this is Show it only once.
Progress across devices
For a user your app has identified, PlayStep keeps their guide progress on the server, so a guide they finished or closed on their laptop does not start again on their phone (SDK 0.10+). The SDK fetches it with the config when the page loads or the app launches, so call identify before PlayStep loads to have it on the first page. For each guide, the server's progress wins over the device's. Anonymous users' progress stays on their device, and on the web it also stays per device on a page that is not https or localhost.
Guides in a row
A guide_completed trigger starts a guide when someone closes the finish card of the guide it names, so one guide can follow another. In the builder it is Starts when › Someone completes another guide, with the guide to follow. A guide cannot follow itself. SDKs before 0.10 never start such a guide on their own; it can still be started from the launcher or with start().
While a finished guide's finish card shows, other triggers wait. When it closes, page triggers for the current page run.
Paths
* matches any run of characters: /invoices/* matches /invoices/new and /invoices/42/edit. On Flutter, paths are route names, so name your routes (settings: RouteSettings(name: '/invoices')) or call PlayStep.page('/invoices').
Leaving a guide part-way
A guide started by a page belongs on the pages its path matches, and after a page step, on the page that step leads to. If the user goes somewhere else, the guide waits with its progress kept: it leaves the screen, the new page's own guide can start, and the guide comes back on its step when the user returns to its page (or loads it later). Coming back is not a new start: guide_shown is sent again only when the guide resumes on a later visit, and then with the source of the start it continues. Starting another guide (from the guide list, the finish screen or start()) sets the one showing aside in the same way rather than dismissing it, so it comes back on its page later.
A step that completes by a tap, an event or your code may itself take the user to another page, so the steps after it go where the user goes, as do guides started any other way (first visit, events, manual), until a page step says which page they are on. Older SDKs (before 0.8) keep a guide left part-way on screen on every page.
Where a guide starts
A trigger starts a guide where the user is. A guide can also name the page it begins on (start_path, Starts on page in its settings), for when someone starts it from elsewhere: picking it in the guide list (Start or Replay), pressing Replay or Next guide on the finish screen, or your code calling start(). If your app gives the SDK its router (navigate, web, Flutter), PlayStep takes the user to that page first and begins on step 1 there, rather than skipping steps the page they came from happens to satisfy. Triggers never navigate, and without a router a guide starts where the user is. A * in the start page is filled in from the same part of the current path; for pages that lack that part, the app can fill it in itself (startPage on the web, startRoute in Flutter).
guide_shown tells your app which happened (source: trigger, launcher or api), in case it wants to react itself.
Events
Events are names you choose, like invoice_page_opened. Report them from your code:
playstep.track('invoice_page_opened')
The same event can start one guide and complete a step of another.
Targeting
A guide only starts for users who match its targeting:
- Platforms: web, Flutter or both.
- Segments: rules on the traits you pass to
identify. All rules must match.
playstep.identify(user.id, { plan: 'pro', guides: 0 })
{ "segments": [{ "trait": "plan", "op": "eq", "value": "pro" }] }
Operators are eq, neq, in (any of a list) and exists. A trait set to null matches no eq, in or exists rule. An operator the SDK does not know (one added in a later version) matches nobody, so a guide never shows to more people than you meant (SDK 0.10+). When several guides match at once, the first one in the published order starts; the others wait.