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.
Copy the snippet below and replace YOUR_TRACK_ID
with your project's values.
Snippet for browser via SDK
1 import ls from "@livesession/browser";2 3 // init a script, trackID is required4 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
1 <script type="text/javascript">2 window["__ls_namespace"] = "__ls";3 window["__ls_script_url"] = "https://cdn.livesession.io/track.js";4 5 !(function (w, d, t, u, n6 ) {7 if (n in w) {8 if (w.console && w.console.log) {9 w.console.log(10 'LiveSession namespace conflict. Please set window["__ls_namespace"].',11 );12 }13 14 return;15 }16 17 if (w[n]) return;18 19 var f = (w[n] = function() {20 f.push ? f.push.apply(f, arguments) : f.store.push(arguments);21 });22 23 if (!w[n]) w[n] = f;24 f.store = [];25 f.v = "1.1";26 27 var ls = d.createElement(t);28 ls.async = true;29 ls.src = u;30 var s = d.getElementsByTagName(t)[0];31 s.parentNode.insertBefore(ls, s);32 })33 (34 window,35 document,36 "script",37 window["__ls_script_url"],38 window["__ls_namespace"],39 );40 41 __ls("init", "<YOUR_TRACK_ID>", {42 keystrokes: false43 });44 __ls("newPageView");45 </script>