Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

RTE Href - Additional Attributes

v1101
Level 5
Level 5

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>

1 Accepted Solution
raj_mandalapu
Correct answer by
Community Advisor
Community Advisor

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');
}
}

View solution in original post

5 Replies
Veena_Vikram
Community Advisor
Community Advisor

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

v1101
Level 5
Level 5
@Veena_Vikram - 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.
raj_mandalapu
Correct answer by
Community Advisor
Community Advisor

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');
}
}

View solution in original post

Veena_Vikram
Community Advisor
Community Advisor

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