1. Component Guide
  2. Intervention
Component

Intervention

An area that contains personalised content to the user

The intervention is used to show personalised content. For instance, if the user has visited multiple pages in the same area of the site, we might want let them know that there are other pages on GOV.UK that would be useful to them. This component would be used to add this personalised content and would indicate to the user that this is not normally part of the page, but has been added for them specifically.

The dismiss link points to the current URL with the “hide-intervention” query string parameter set to “true”. The backend should check for this string in order to render the same page without the intervention.

Search for usage of this component on GitHub.

How it looks (preview) (preview all)

You should renew your permit every 6 months.

How to call this component

<%= render "govuk_publishing_components/components/intervention", {
  suggestion_text: "You should renew your permit every 6 months."
} %>

Accessibility acceptance criteria

The intervention component must:

  • have a border colour contrast ratio of more than 4.5:1 with its background to be visually distinct
  • prevent screen readers from announcing the dismiss link icon

Links in the component must:

  • accept focus
  • be focusable with a keyboard
  • be usable with a keyboard
  • indicate when they have focus
  • change in appearance when touched (in the touch-down state)
  • change in appearance when hovered
  • be usable with touch
  • be usable with voice commands
  • have visible text
  • have meaningful text

Other examples

With suggestion link (preview)

Based on your browsing you might be interested in Travel abroad: step by step

<%= render "govuk_publishing_components/components/intervention", {
  suggestion_text: "Based on your browsing you might be interested in",
  suggestion_link_text: "Travel abroad: step by step",
  suggestion_link_url: "/travel-abroad"
} %>

With dismiss link (preview)

You should renew your permit every 6 months.

Hide this suggestion

<%= render "govuk_publishing_components/components/intervention", {
  suggestion_text: "You should renew your permit every 6 months.",
  dismiss_text: "Hide this suggestion"
} %>

With suggestion link only (preview)

<%= render "govuk_publishing_components/components/intervention", {
  suggestion_link_text: "You can now apply for a permit online.",
  suggestion_link_url: "/permit"
} %>

With hide (preview)

This example is for when we want to hide by default and display to the user based on some logic, either in the backend or with Javascript.

<%= render "govuk_publishing_components/components/intervention", {
  suggestion_link_text: "You may be invited to fill in a questionnaire",
  suggestion_link_url: "/questionnaire",
  hide: true
} %>

Open suggestion link in new tab (preview)

When sending users to another online task, you don’t want to completely hijack their original flow on GOV.UK. Adding the option to open links in a new tab helps to address this. Link text should tell the user that the link opens in a new tab. Note: “(opens in a new tab)” is added to link text if the phrase isn’t included.

<%= render "govuk_publishing_components/components/intervention", {
  suggestion_link_text: "You can now apply for a permit online",
  suggestion_link_url: "www.google.com/permit",
  new_tab: true
} %>

With data attributes (preview)

This example shows the use of suggestion_data_attributes and dismiss_data_attributes for click tracking.

Based on your browsing you might be interested in Travel abroad: step by step

Hide this suggestion

<%= render "govuk_publishing_components/components/intervention", {
  suggestion_text: "Based on your browsing you might be interested in",
  suggestion_link_text: "Travel abroad: step by step",
  suggestion_link_url: "/travel-abroad",
  suggestion_data_attributes: {
    module: "gem-track-click",
    "track-category": "interventionBanner",
    "track-action": "interventionClicked",
    "track-dimension": "Travel abroad: step by step",
    "track-dimension-index": "29",
    "track-label": "clicked suggestion"
  },
  dismiss_text: "Hide this suggestion",
  dismiss_data_attributes: {
    module: "gem-track-click",
    "track-category": "interventionBanner",
    "track-action": "interventionDismissed",
    "track-dimension": "Hide this suggestion",
    "track-dimension-index": "29",
    "track-label": "hid the intervention"
  }
} %>