RTE Href - Additional Attributes | Community
Skip to main content
Level 5
September 24, 2020
Solved

RTE Href - Additional Attributes

  • September 24, 2020
  • 4 replies
  • 2976 views

Hello Community - We have a requirement to add some additional tags (highlighted below) as part of href link. Currently we have an plugin/option in Rich Text Editor to specify the target/href url and target (self/blank). We don't need to show the highlighted attributes/options in the plugin UI for authors and should generated once the link is authored. I see some articles that specify some changes related to "link-options.js". Not sure if this is correct. These additional data is required for analytics. Can someone provide some details on how to implement this?

 

<a title="Privacy Policy" href="https://www.adobe.com"
data-asset-id="container-727741347-link-0"
data-asset-type="LINK"
data-asset-name="Privacy Policy"
target="_blank">
Privacy Policy</a>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by raj_mandalapu

If you have good knowledge on JS then you can customize this "link-options.js", I have done similar implementation in classic UI, but not in Touch UI. you need to put some additional effort for R&D

 

Another approach is you can write a sling model, that reads the content of the rich text editor, and inside the sling model use regex to find out anchor links and replace anchor links by adding custom attributes.

 

My preferable approach is, you are adding custom attributes for analytics tracking, I feel, on click on the anchor link you can call below function, link name you can read from the anchor link title. Link type and id either you can hardcode or you can write some logic.

 

function trackLink(link) {
if (typeof _satellite !== "undefined" && typeof digitalData !== "undefined" ) {
digitalData.page.link.name = "Privacy Policy";
digitalData.page.link.type = "LINK";
digitalData.page.link.id = "your custom id specific logic";
_satellite.track('anchorLink');
}
}

4 replies

VeenaVikraman
Community Advisor
Community Advisor
September 25, 2020

@v1101 From where will the Values for the additional attributes be pulled ? 

v1101Author
Level 5
September 25, 2020
@veenavikraman - ID is the unique field which is assigned with some quto-generated value. Other fields, we can get the values from the link text value.
arunpatidar
Community Advisor
Community Advisor
September 27, 2020
raj_mandalapu
raj_mandalapuAccepted solution
Level 7
September 29, 2020

If you have good knowledge on JS then you can customize this "link-options.js", I have done similar implementation in classic UI, but not in Touch UI. you need to put some additional effort for R&D

 

Another approach is you can write a sling model, that reads the content of the rich text editor, and inside the sling model use regex to find out anchor links and replace anchor links by adding custom attributes.

 

My preferable approach is, you are adding custom attributes for analytics tracking, I feel, on click on the anchor link you can call below function, link name you can read from the anchor link title. Link type and id either you can hardcode or you can write some logic.

 

function trackLink(link) {
if (typeof _satellite !== "undefined" && typeof digitalData !== "undefined" ) {
digitalData.page.link.name = "Privacy Policy";
digitalData.page.link.type = "LINK";
digitalData.page.link.id = "your custom id specific logic";
_satellite.track('anchorLink');
}
}

VeenaVikraman
Community Advisor
Community Advisor
September 29, 2020

I think may be a better approach is to handle it with FE of that is possible.