With data attributes
This example shows the use of suggestion_data_attributes
,
dismiss_data_attributes
for click tracking on the dismiss section <p> tag, and dismiss_link_data_attributes
for adding attributes to the dismiss link tag.
Other data attributes can also be applied as required. 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/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: {
"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",
name: "another-campaign-name",
dismiss_data_attributes: {
"track-category": "interventionBanner",
"track-action": "interventionDismissed",
"track-dimension": "Hide this suggestion",
"track-dimension-index": 29,
"track-label": "hide the intervention"
},
dismiss_link_data_attributes: {
"track-category": "example"
}
} %>