How to record user's keystrokes?

Kamil Drazkiewicz
Kamil Drazkiewicz1 minMay 11, 2022

Regardless of keystroke configuration, LiveSession never records passwords (inputs with type="password") or credit card information (all inputs with autocomplete property starting with cc-)

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 object - __ls("init", "YOUR_TRACK_ID", { keystrokes: true }). If you use this method then LiveSession will track every input in your application (excluding passwords and credit cards).

After turning global keystrokes tracking on, You should test this option on your development environment first to ensure that all sensitive data is not exposed to our tracker.

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("init", "YOUR_TRACK_ID", { keystrokes: true });
__ls("newPageView") 
</script>
<!-- LiveSession.io code -->

To exclude input from tracking manually you can add data-ls-disabled property to your HTML inputs.

<input data-ls-disabled type="text" placeholder="Sensitive value"/>

2. Whitelist specific inputs on your website

Another option is to track only specific inputs that are important for you. Add data-ls-enabled to input which value you want to track.

<input data-ls-enabled type="text" placeholder="My unicorn name"/>

Related articles

    Start understanding
    your users today

    Free 14-day trial

    No credit card required

    Easy setup