Getting started
WelcomeAPI Changelog
JavaScript API
IntroductionConfigurationMethodsgetSessionURLinitidentifyinvalidateSessionnewPageViewsetOptionssetCustomParamsoffoptOutdebugRecording conditionsRate limitsTutorialsPlatforms
Rest API
Webhooks

Methods

getSessionURL

Get URL to current session.

__ls("getSessionURL", callback)

This method works asynchronusly. callback fires after session is inited.

Return

NameTypeValue
urlstringhttps://app.livesession.io/app/session/{visitor_id}/{session_id}
isNewSessionbool-

Example

__ls("getSessionURL", function(url, isNewSession) {
// do only if it's a new session
if (isNewSession) {
YOUR_API.addSessionURL(url);
}
});

Integration with other software:

__ls("getSessionURL", function(url, isNewSession) {
if (isNewSession) drift.track("LiveSession recording URL", { sessionURL: url });
});




init

Init LiveSession tracking stript. You can find your website tracking ID in LiveSession -> Settings -> Websites.

__ls("init", trackingID, options)

Options

See configuration section

Example

__ls("init", "abc.cdef");

With options:

__ls("init", "abc.cdef", { keystrokes: true });




identify

Identify user and custom data to session.

__ls("identify", data)

Calls to Record Session API (rs.livesession.io) for this method are rate limited per-session to 5 requests per second and 10 request per minute. If these limits are exceeded, new values won't be set.

Validation

NameTypeMaximum lengthDetails
namestring128Displays user names in app
emailstring128Displays user email
paramsobject50 items{key:value} JSON object

Example

__ls("identify", { name: "John Doe", email: "john.doe@example.com" });

With params:

__ls("identify", {
name: "John Doe",
email: "john.doe@example.com",
params: {
order_id: "123-abc-def",
plan: "premium",
},
});

Users' name and email will be the same across all of their sessions.





invalidateSession

Close curent session.

__ls("invalidateSession")

Example

__ls("invalidateSession");




newPageView

Start recording user's visit and add it to session when conditions fulfilled. If session doesn't exists it also create new session.

__ls("newPageView", options)

Options

NameTypeDescription
titlestringOverwrite page title
conditionsarray of objectsConditions for starting new pageView (learn more).

Example

__ls("newPageView");

with options:

__ls("newPageView", { title: "Anonimized page title" });

with conditions (learn more):

__ls("newPageView", {
conditions: [{ type: "event", name: "MouseClick", operator: "contain", key: "path", value: ".add-cart" }],
});




setOptions

Set options and init LiveSession tracking stript (if it's not inited). You can find your website ID and account ID in LiveSession -> Settings -> Websites.

__ls("setOptions", options)

Options

See configuration section

Example

__ls("setOptions", { accountID: "abc", websiteID: "cdef" });

Set keystrokes:

__ls("setOptions", { keystrokes: true });




setCustomParams

Set custom properties to session.

__ls("setCustomParams", data)

Calls to Record Session API (rs.livesession.io) for this method are rate limited per-session to 5 requests per second and 10 request per minute. If these limits are exceeded, new values won't be set.

Validation

NameTypeMaximum lengthDetails
dataobject50 items{key:value} JSON object

Example

__ls("setCustomParams", {
params: {
order_id: "123-abc-def",
plan: "premium",
},
});




off

Turn LiveSession script off.

__ls("off")

Example

__ls("off");




optOut

Set optOut flag. This method sets a __ls_optout cookie on current domain to inform LiveSession script to turn off.

__ls("optOut", value)

Example

__ls("optOut", true);




debug

Set debug logging mode.

__ls("debug", value)

Example

__ls("debug", true);