1. Component Guide
  2. Form checkboxes
  3. Checkboxes with data attributes
Form checkboxes example

Checkboxes with data attributes

Data attributes such as tracking can be applied if required. This will fire tracking identical tracking events on check and uncheck. See below to send different events on uncheck.

How it looks (preview)

How to call this example

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