AEM Analytics: Sending Original Field Values in Locales. Part 1

Share article

AEM-analytics

Explore more tips about content migration

AEM analytics give you valuable insights into visitors’ journeys on a website. To map this behavior accurately, you need to tune analytics in AEM programmatically. Tuning becomes especially important and tricky if you have a multi-language site — but if you know AEM MSM best practices, then there will be no need to hit the panic button. Learn how to make your AEM analytics integration smooth and successful!

In this article, the Exadel Marketing Technology Team suggests a solution for managing AEM analytics while having different locales with translated content.

AEM analytics tutorial at your service There are quite a few reasons why we might need to pass English text to a data layer when a user clicks on a component. This could be for a button, a link, a title, or something else. By passing the English text, we’ll be able to generate user interaction reports for all locales, regardless of the localized UI language. What that means is that we need to somehow store the original text value that will not be translated for locales. Let’s break down the algorithm of our actions into several steps.

Tuning analytics in AEM: Plain Text Field

For each field whose value should be sent in English to AEM analytics, we’re going to create a hidden field with the name “./{fieldName}.id”.

Author Dialog: Additional config for AEM analytics So, for a “title” field, we’ll have the following:

ClientLibs: Storing original values that should pass to AEM analytics As you noticed, the “title” field has granite:class=”analytics-cta-id”. This is being handled in a separate clientlib.

set-cta-id.js:

Back end: A general approach to use AEM analytics data Now, we need to handle it properly on the back end.

TitleId.java:

TitleIdObject.java:

TitleIdInjector.java:

For any back-end sling model, we can inject this title field:

And in html template, that will look like this:

On the front-end side, data-an-id and data-an-title will be used to handle analytics in AEM properly.

Managing existing components to make AEM analytics work

The proposed solution will work fine for newly-created components, but to get the old components to work, we need to make some adjustments. We will have an OnDeploy script to preset title.id values to make AEM analytics work.

OnDeploySiteBase.java:

AnalyticsConverterScriptBase.java:

TitleIdConverterScriptBase.java:

TitleIdConverterScript.java:

These adjustments were all made to manage plain text fields (textfield, textarea). In the next article about AEM analytics, we will have a look at RTE fields.

Give your analytics in AEM a boost

Should you have any questions about AEM analytics integration processes or AEM MSM functionality workarounds, contact us! We can help you fine-tune any AEM environment so that it aligns with your marketing objectives and grasps the necessary data to drive your sales strategy in the right direction.

Author: Iryna Ason