Javascript API

The Userpilot Javascript SDK officially supports the following methods.

identify (userId, [properties])

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

userpilot.identify("123", {

name: "John",

email: "john@example.com",

created_at: "1519205055"

// Additional user properties

// projectId: "1"

// trialEnds: '2019-10-31T09:29:33.401Z'

});

anonymous

Assign a session based unique ID for the current user.

reload([URL])

userpilot.reload();

/* You can also call reload on a fake URL */

userpilot.reload({url: 'https://example.com/hello'});

Update Userpilot content when there is a change in the page state.

track (name, [properties])

userpilot.track("invitedAgent", {

name: "Sam",

email: "sam@example.com"

});

Tracks a custom event taken by the current user.

trigger (contentId)

Force a certain Userpilot content to show for the current user. This method completely overrides any targeting conditions that have been set for that content. 

on (event, callback)

Trigger a callback function on an event.

List of all the methods that will occur during an experience life cycle.

- started

Triggers when the flow starts.

{id: 1, token: 1576146927zJny2049}

- completed

Triggers when the flow gets completed.

{id: 1, token: 1576146927zJny2049}

- dismissed

Triggers when the flow gets dismissed.

{id: 1, token: 1576146927zJny2049}

- step

Triggers when there is an interaction with the UI pattern.

{id: 1, token: 1576146927zJny2049, step: 1, totalSteps: 15}

userpilot.on('completed', function(event){

alert('Experience completed');

});

off (event)

Remove a callback function attached to an event.

once (event, callback)

Trigger the callback function only once.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.