1. Collections Component Guide
  2. Form checkboxes
  3. Checkboxes with data attributes and custom uncheck event category
Form checkboxes example

Checkboxes with data attributes and custom uncheck event category

It can send a different tracking event category for an uncheck. This is handled automatically

How it looks (preview)

How to call this example

<%= render "govuk_publishing_components/components/checkboxes", {
  name: "With tracking and a custom uncheck category",
  items: [
    {
      label: "Tracked",
      value: "tracked",
      data_attributes: {
        track_category: "checkboxClicked",
        untrack_category: "checkboxUnchecked",
        track_label: "/news-and-communications",
        track_action: "news",
        track_options: {
          dimension28: 2,
          dimension29: "Tracked"
        },
        controls: null,
        "aria-controls": null,
        exclusive: null
      }
    }
  ]
} %>