Getting started
WelcomeAPI Changelog
JavaScript API
IntroductionConfigurationMethodsRecording conditionsRate limitsTutorialsCustom session start triggerTracking users across multiple subdomainsExcluding senstivie page contentIntegrate with other softwaresPlatforms
REST API (BETA)

Tutorials

List of useful examples with JavaScript API.


Custom session start trigger


If you need a custom trigger for a starting a session you can customize default tracking script. To make it works, add your conditions before calling __ls("newPageView"):

__ls("init", "YOUR_TRACK_ID", { keystrokes: true });
// sample condition
if (false === MY_API.isUserType("Admin")) {
__ls("newPageView");
}

You can also use newPageView() method conditions.





Tracking users across multiple subdomains


To track users across multiple subdomains you have to set a rootHostname option to .your-domian.com (note that the first character is a dot) when calling init or setOptions method. :

__ls("init", "YOUR_TRACK_ID", { rootHostname: ".your-domian.com" });
__ls("newPageView");




Excluding senstivie page content


You can add a data-ls-disabled attribute to exclude an HTML element. This attribute will anonymize the content (text will be replaced with asterisks).

The attribute is applied to all child elements, too. In the case of regular clicks and rage clicks, clicking on an anonymized element won’t reveal the text value.

Anonymize whole text content inside .user-info:

<div data-ls-disabled class="user-info">
<p>Logged as: <span>John Doe</span></p>
</div>

Anonymize only sensitive element:

<div class="user-info">
<p>Logged as: <span data-ls-disabled>John Doe</span></p>
</div>

You can also use data-ls-enabled to make content visible. Useful if some child elements could be visible.

<div data-ls-disabled class="article">
<p>Lorem ipsum sensitive article.</p>
<button data-ls-enabled>Subscribe</button>
</div>




Integrate with other softwares


You can simple integrate LiveSession with other softwares by using getSessionURL method:

Google Analytics:

__ls("getSessionURL", function(url, isNewSession){
if(isNewSession){
ga('send', {
hitType: 'event',
eventCategory: 'LiveSession recording',
eventAction: url,
nonInteraction: 1
})
}
})

LiveChat:

__ls("getSessionURL", function(url, isNewSession){
if(isNewSession){
LC_API.set_custom_variables([{name: "LiveSession", value: url}]);
}
})

Segment :

__ls("getSessionURL", function(url, isNewSession){
if(isNewSession){
analytics.track('LiveSession Recording', {url: url});
}
})

Create your own integration and let us know at hello@livesession.io