With data attributes
Data attributes can be added to both the parent element and the individual share links, as shown. Note that the component defaults to having a data-module
of ga4-link-tracker
if tracking is enabled, but this is preserved even if another value for module is passed.
How it looks (preview)
How to call this example
<%= render "govuk_publishing_components/components/share_links", {
data_attributes: {
module: "example-passed-module"
},
links: [
{
href: "/facebook-share-link",
text: "Facebook",
icon: "facebook",
data_attributes: {
meeting: "hello"
}
},
{
href: "/twitter-share-link",
text: "Twitter",
icon: "twitter",
data_attributes: {
departing: "goodbye"
}
}
]
} %>