AEM-analytics

Explore more tips about content migration

Content migration in AEM is a difficult task unless you know the necessary workarounds and ways to manage content in AEM analytics. In the previous article, our Marketing Technology Practice team was looking at how to manage analytics for plain text fields. In today’s post, we will look at an AEM RTE field in particular.

Managing Links Inside AEM Rich Text Editor

Managing AEM RTE analytics will be a little different from managing plain text fields. Since the AEM RTE text field stores HTML, we’ll need to find a way to search for all the links inside HTML and then inject the data-an-id attribute into these links. The implementation will consist of 2 parts: on the fly HTML update on AEM RTE editing and managing already existing components.

Clientlibs: Injecting Attributes into Links
The following code listens to the AEM RTE input field update. Additionally, if you add a link, this JavaScript code will add the needed attribute to the link inside the RTE field.

As you can see, this js code is looking for AEM Rich Text Editor fields with the “analytics-cta-rte-id” class, so we will add this class to the AEM RTE field:

NOTE: Don’t forget to add your client lib category into “extraClientLibs” in the dialog.

Now, when you’re changing any text in the AEM Rich Text Editor, it will automatically rewrite all the links inside.

AEM Rich Text Editor: Managing Existing Components

In the AEM Analytics article for the plain text fields, we’ve defined a TitleIdConverterScriptBase.class as a base class to rewrite all the existing components with a text field/text area.

Here, however, we provide an analogical class for AEM RTE fields:

Now, each time you change analytics for a component with an AEM RTE field, you can add a new execution script:

Making RTE in AEM Work Efficiently

These are the code snippets you need to make changes in AEM Rich Text Editor . We came up with this solution while working on a project for one of our clients. If you’re facing problems when working on similar tasks related to AEM Touch UI Rich Text Editor, this can be a workable example of how to manage analytics for different types of fields in AEM.

Author: Iryna Ason

How can we help you?
Contact Us