How to record user's keystrokes?

LiveSession protects end-users privacy on default, so it doesn't track what people type in into inputs. If you want to enable keystrokes tracking, then you have two possible methods to do so:

1. Enable global keystrokes tracking

Add keystrokes: true to your tracking code options. If you use this method then LiveSession will track every input in your application (excluding inputs with type="password" and credit card inputs - all inputs with autocomplete property starting with cc-). You should test this option on your staging / development environment first to ensure that all sensitive data is not exposed to our tracker. To exclude input from tracking manually you can add data-ls-disabled property to your HTML inputs.

After change, it should look like that:


  <!-- LiveSession.io code -->
  <script type="text/javascript">
    !function(w, d, t, u) {
        if (w.__ls) return; f = w.__ls = function() { f.push ? f.push.apply(f, arguments) : f.store.push(arguments)};
        if (!w.__ls) w.__ls = f; f.store = []; f.v = "0.1b";

        ls = d.createElement(t); ls.async = true; ls.src = u;
        s = d.getElementsByTagName(t)[0]; s.parentNode.insertBefore(ls, s);
    }(window, document, 'script', ('https:' == window.location.protocol ? 'https://' : 'http://') + 'cdn.livesession.io/track.js');
    
    // CHECK LINE OF CODE BELOW, IT'S IMPORTANT 
    __ls("setOptions", { accountID: "YOUR_ACCOUNT_ID", websiteID: "YOUR_WEBSITE_ID", keystrokes: true });
    __ls("newPageView") 
  </script>
  <!-- LiveSession.io code -->
          

2. Whitelist specific inputs on your website

You can also don't use global option for keystrokes tracking and only whitelist inputs that are important for you. Add data-ls-enabled to specific input that you want to be tracked.