Track Checkbox State

Remember the state of a checkbox as the user changes pages

Overview

Remember whether a checkbox is clicked or not, and maintain that state on each page load as the user navigates through your site.

Good for, e.g. a day/night mode switch.

Implementing

Place this in your SITE-wide /BODY custom code area;

<script>
// Handle checkbox tracking
// both checked and unchecked events 
$("input[type='checkbox'][wfu-bind-tracked]").change(function() {
  const label = $(this).attr("wfu-bind-tracked");
  if(this.checked) 
    window.tracker.track(label);
  else
    window.tracker.untrack(label);
  updateTracked();
}); 
</script>

Also place this code inside and at the end of the updateTracked() function in your site-wide /BODY custom code.

Last updated

Was this helpful?