Skip to main content
The Pyne JavaScript SDK provides functions to interact with guides and listen for events directly from your application’s frontend code. Ensure the main Pyne installation script is included on your page before calling these functions.

Identify User (pyne.identify)

This is the primary method for connecting user data to Pyne, enabling targeting and personalization.
// Identify the user and their properties
pyne(
  "identify",
  userId, // Unique User ID (string or number)
  userProperties // Optional: User Properties (object)
);

// Example:
pyne("identify", currentUser.id, {
  name: currentUser.name,
  email: currentUser.email,
  created_at: currentUser.created_at, // ISO-8601 format
});

// Clear user session (on logout):
pyne("identify", null);
See the Connect User Data page for more details and examples.

Manual Guide Control

These functions allow you to programmatically control guide playback.
/**
 * Start a specific guide by its ID.
 * This bypasses targeting rules but requires the guide to be Published.
 * guideId (string): The ID of the guide to start.
 */
pyne("startTour", guideId);

/**
 * Forcefully terminate the currently active guide.
 */
pyne("terminateCurrentTour");
Find the Guide ID in the URL when editing a guide in the Pyne dashboard: .../guides/GUIDE_ID_HERE Guide ID in
URL

Event Listeners

Register callbacks to react to various events during the guide lifecycle. Tour Lifecycle Events:
// Guide started
pyne("onTourStarted", ({ id }) => {
  console.log(`Guide started: ${id}`);
  // Example: Send analytics event
});

// Guide completed successfully by the user
pyne("onTourFinished", ({ id }) => {
  console.log(`User finished guide: ${id}`);
});

// Guide terminated by the system (e.g., error, API call)
pyne("onTourTerminated", ({ id }) => {
  console.log(`Guide terminated: ${id}`);
});

// Guide dismissed by the user (e.g., clicking close button)
pyne("onTourDismissed", ({ id }) => {
  console.log(`Guide dismissed by user: ${id}`);
});
Avatar Interaction Events:
// User clicked the minimize button on the avatar
pyne("onUserMinimizedAvatar", ({ id }) => {
  console.log(`User minimized avatar for guide: ${id}`);
});

// User clicked the minimized avatar to expand it
pyne("onUserExpandedAvatar", ({ id }) => {
  console.log(`User expanded avatar for guide: ${id}`);
});
Tour State Events:
// Guide execution suspended (e.g., waiting for element, page change)
pyne("onTourSuspended", ({ id }) => {
  console.log(`Guide suspended: ${id}`);
});

// Guide execution resumed after being suspended
pyne("onTourUnsuspended", ({ id }) => {
  console.log(`Guide unsuspended: ${id}`);
});