With Mouseflow, you can use Custom Variables to push all cookies and their values into our platform.

Use this to

See which cookies are associated with a session or sort/filter for specific sessions based on cookie data.

Note: You cannot use this feature to store personal data or to link a session/recording with an individual user/other personal data.


Setup

A: To use this feature, simply add the following JavaScript to any page(s) you wish to identify cookies from.

<script type="text/javascript"> 
for (var i = 0; i < document.cookie.split(';').length; i++) {
window._mfq = window._mfq || [];
var cookie = document.cookie.split(';')[i].trim();
var cookieName = cookie.split('=')[0];
var cookieValue = cookie.split('=')[1];
_mfq.push(["setVariable", cookieName, cookieValue]);
}
</script>

Note: By default, custom variables are session-scoped so a cookie that has an initial value that is later changed (updated) will be stored only with the latest/most recent value.

B: To change this behavior (preserving the initial value and ensuring that it doesn't get overwritten), use this code snippet instead:

<script type="text/javascript"> 
for (var i = 0; i < document.cookie.split(';').length; i++) {
window._mfq = window._mfq || [];
var cookie = document.cookie.split(';')[i].trim();
var cookieName = cookie.split('=')[0];
var cookieValue = cookie.split('=')[1];
_mfq.push(["setVariable", cookieName, cookieValue, "session", false]);
}
</script>
Did this answer your question?