Get Started
/
Introduction

Introduction

Learn how to start using LiveSession on browser.

This is the simplest way to get LiveSession up and running on browser environment. It only takes a few minutes. First install @livesession/browser package:

npm install @livesession/browser

Copy the snippet below and replace YOUR_TRACK_ID with your project's values.

Snippet for browser via SDK
import ls from "@livesession/browser";
// init a script, trackID is required
ls.init("<YOUR_TRACK_ID>", options, sdkOptions);

Or, if you want to use window API then add below snippet within the <head> tags at the base of your product - ideally just before the closing </head> tag. This ensures LiveSession loads on any page users visit.

You can find the snippet pre-filled with this data in your project settings.

Snippet via window API
<script type="text/javascript">
window["__ls_namespace"] = "__ls";
window["__ls_script_url"] = "https://cdn.livesession.io/track.js";
!(function (w, d, t, u, n
) {
if (n in w) {
if (w.console && w.console.log) {
w.console.log(
'LiveSession namespace conflict. Please set window["__ls_namespace"].',
);
}
return;
}
if (w[n]) return;
var f = (w[n] = function() {
f.push ? f.push.apply(f, arguments) : f.store.push(arguments);
});
if (!w[n]) w[n] = f;
f.store = [];
f.v = "1.1";
var ls = d.createElement(t);
ls.async = true;
ls.src = u;
var s = d.getElementsByTagName(t)[0];
s.parentNode.insertBefore(ls, s);
})
(
window,
document,
"script",
window["__ls_script_url"],
window["__ls_namespace"],
);
__ls("init", "<YOUR_TRACK_ID>", {
keystrokes: false
});
__ls("newPageView");
</script>
Built with

Show your support! Star us on GitHub ⭐️