1. Component Guide
  2. Cards (experimental)
  3. With data attributes
Cards (experimental) example

With data attributes

Data attributes can be passed to individual links within the component as shown.

Note that the component does not include built in tracking. If this is required consider using the track click script.

How it looks (preview)

How to call this example

<%= render "govuk_publishing_components/components/cards", {
  items: [
    {
      link: {
        text: "Benefits",
        path: "http://www.gov.uk",
        data_attributes: {
          track_category: "homepageClicked",
          track_action: "track-action",
          track_label: "track-label",
          track_dimension: "track-dimension",
          track_dimension_index: 29,
          track_value: 9
        }
      },
      description: "Includes eligibility, appeals, tax credits and Universal Credit"
    },
    {
      link: {
        text: "Births, deaths, marriages and&nbsp;care",
        path: "http://www.gov.uk",
        data_attributes: {
          track_category: "homepageClicked",
          track_action: "track-action",
          track_label: "track-label",
          track_dimension: "track-dimension",
          track_dimension_index: 29,
          track_value: 9
        }
      },
      description: "Parenting, civil partnerships, divorce and Lasting Power of Attorney"
    }
  ]
} %>