JavaScript API
Everything on window.Cueston once the snippet is on the page.
Every method can be called before the script has loaded: the queue in the first snippet tag holds the calls and replays them. Cueston is also callable as a function, Cueston("track", "Report exported").
Methods
| Method | What it does |
|---|---|
Cueston.init({ key, locale?, debug?, apiHost? }) | Start the SDK from code instead of the script tag's data-key. Ignored once started. |
Cueston.identify(userId, traits?, { userHash? }) | Tell Cueston who is signed in. Traits drive targeting. See Identify users. |
Cueston.reset() | Sign out: forget the user, start a new anonymous id and clear local frequency state. |
Cueston.reset(type, id) | Show one item again, for example Cueston.reset("tour", 42). Cueston.reset(id) does it for every type. |
Cueston.page() | Check targeting again after a route change. Single-page apps are detected automatically; call it if you use a custom router. |
Cueston.track(event, properties?) | Record a custom event. It counts toward behaviour targeting, checklist items and goals. |
Cueston.start(tourId) | Start a tour now, for example from a "Take the tour" button. |
Cueston.show(type, id) | Show a published item now: "tour", "tooltip", "banner", "checklist", "survey" or "announcement". |
Cueston.dismiss(type, id) | Close an item that's showing. |
Cueston.on(event, callback) | Listen for an event (below). |
Cueston.off(event, callback?) | Stop listening. Without a callback, removes every listener for that event. |
Cueston.destroy() | Remove everything Cueston added to the page and stop. |
Cueston.version is the SDK version. Cueston.refresh() and Cueston.getUser() still work for older integrations.
Custom events
Cueston.track("Report exported", { format: "csv", rows: 1200 });
Event names are up to 100 characters. Properties are up to 1 KB of JSON. Use events in audience rules ("performed Report exported at least 3 times in 30 days"), to complete checklist items, and as goals.
Events
Cueston.on("complete", (event) => {
if (event.contentType === "tour") analytics.track("Tour finished", { tourId: event.contentId });
});
| Event | When |
|---|---|
ready | Published content has loaded. |
identify, reset, page, track | After the matching method ran. |
impression | An item was shown. |
step_view | A tour step, or a tooltip's card, was shown. |
cta_click | Someone clicked an item's call to action. |
complete | Someone finished a tour or acted on an item. |
dismiss | Someone closed an item. |
skip | Someone skipped a tour. |
target_missing | A step's element wasn't found on the page. |
holdout, goal | Experiment events: the visitor is in the control group, or reached the goal. |
destroy | Cueston.destroy() ran. |
Guidance events carry { type, contentType, contentId, stepIndex?, url, ts }. Checklists and surveys also send their own events, such as checklist_item_complete. In preview, events have preview: true and nothing is recorded.