Javascript API

The Appcues Javascript SDK officially supports the following methods as part of it's API:

identify (userId, [properties])

Identifies the current user with an ID and an optional set of properties.

Example:

Appcues.identify("1234", {
    name: "Jonathan",
    createdAt: 578721600000,
    company: "Appcues"
});

anonymous

Generates a session-based unique ID for the current user.

Example:

Appcues.anonymous();

page

Notifies the SDK that the state of the application has changed.

Example:

Appcues.page();

track (eventName, [eventProperties])

Tracks a custom event (by name) taken by the current user, along with any properties about that event.

Example:

Appcues.track("Clicked button", {
    color: "red",
    buttonText: "Get started"
});

show (flowId)

Force a specific Appcues flow to appear for the current user. This method ignores any targeting that is set on the flow.

Example:

Appcues.show("-ABCD123");

on (eventName, callbackFn, [context])

Fire the callback function when the given event is triggered by the SDK. The events triggered by the SDK are:

  • flow_started — a flow is first started
  • flow_completed — a flow is completed
  • flow_skipped — a flow is skipped
  • step_interacted — a user interacts with a step in the flow, like clicking the "Next" button
  • form_submitted — a form is submitted
  • form_field_submitted — triggered for each individual field in the submitted form
  • all — listen for all events emitted by the SDK

Example:

Appcues.on("flow_started", function() {
    console.log("Appcues started a flow.");
});

off (eventName, callbackFn, [context])

Undoes a corresponding on call.

Example:

Appcues.off("flow_started");

once (eventName, callbackFn, [context])

Fire the callback function once the next time the given event is triggered by the SDK.

Example:

Appcues.once("flow_started", function() {
    console.log("Appcues started a flow.");
});

reset

Clears all known information about the current user in this session. This is useful when your user logs out of your application.

Example:

Appcues.reset();

debug (enable = true)

Puts the SDK in debug mode, showing more information about the SDK's inner workings.

Example:

Appcues.debug();

Still need help? Contact Us Contact Us