Blogs > Targeting in AEM - Part 1

AEM Sites

Targeting in AEM - Part 1

Infodales Tech Solutions | August 01, 2024

Content personalization in short means delivering the right content to the right person in real-time.

The targeting engine is the mechanism that drives the logic for targeted content. You can use either AEM or Adobe Target as the targeting engine, AEM provides a built-in targeting engine that processes page requests and determines the content to display. AEM as a targeting engine only supports Experience Targeting but Adobe Target should be used for A/B testing.

Let us see how to use the AEM targeting engine to enable the experience targeting for a web page.

Setup ContextHub

ContextHub is a framework for storing, manipulating, and presenting context data. The ContextHub Javascript API enables us to access stores to create, update, and delete data as necessary. To enable the ContextHub features and to link to the ContextHub JavaScript libraries, including the <contexthub> component in the <head> section of our web page.

Add the below HTL code to the overridden customheaderlibs.html file of your page component(here the page component is extending from core page component - core/wcm/components/page/v2/page)

<sly data-sly-resource=" ${'contexthub' @ resourceType = 'granite/contexthub/components/contexthub'}"/>

image

ContextHub includes a segmentation engine that manages segments and determines which segments are resolved for the current context.

Once the ContextHub is enabled for the project, client context data can be explored through the browser local storage.

image1

Configuration Browser - EnableContextHub Segments

Enable the ContextHub segments for your site under Configuration Browser.

Tools → General → Configuration Browser → Select the project → Properties → Check ContextHub Segments

Save and Close

image2

Configure Segment Path and ContextHub Path

Assign Segment path and ContextHub path to your site root node, the default ContextHub path is /libs/settings/cloudsettings/legacy

& segment path — /conf/<tenant>/settings/wcm/segments

image3

Create Brand

Create a Brand to manage the Audiences through Activities console,

Tools → Personalization → Activities, Create Brand

Select Brand Template, add a title, and Create.

image4

Create Audiences - Create ContextHub Segment

An audience, called segment in ContextHub, is a class of visitors defined by specific criteria, which then determines who sees a targeted activity.

Create the required Audiences,

Tools → Personalization → Audiences,

Create ContextHub Segments under the corresponding project.

image5

Specify the required boost factor, If there is more than one segment that gets resolved the one with a higher boost factor is selected.

image6

Create.

Assign the segments to the audience accordingly (similarly as shown below), by editing the segment we've created.

image7

Create Activities

Activities consist of audiences that you are targeting, and the period of time when the targeting is applied.

First Create an Area under Brand and create the Activity inside the Area,

Tools → Personalization → Activities

Enter Title, Name and select the Target Engine as ContextHub.

image8

Add Experience for each audience

image9

Set the Duration and Priority

image10

And Save.

Enable Target Configuration

Enable the Target Configuration — Brand, Area to the root page properties or to the specific page(you can configure more than one brand).

image11 image12

Save and Close.

Now we are done with all the configurations and we can go ahead with the authoring part which will be done in the targeting mode of AEM.

Author Targeted Content

Author targeted content using the Targeting mode of AEM. Targeting mode provides tools for creating content for the experiences of your marketing activities.

Select Targeting Mode from the Dropdown.

image13

Select the Brand and Activity and click on Start Targeting.

image14

On required components select the Target option.

image15

Now select the Audience and define the experience for the components,

Default

Default experience

Summer Female

the experience for female users in Summer

Summer Male

the experience for male users in Summer

Winter Female

the experience for female users in Winter

Winter Male

the experience for male users in Winter

Select the corresponding audience and edit the component data, also we need to set the targeting engine i.e, ContextHub, by clicking on settings.

image16 image17

Now author the targeted component according to the audiences.

image18

Summer Female:

image19

Similarly, edit the authoring for the rest of the audiences accordingly.

Summer Male:

image20

Winter Female:

image21

Winter Male:

image22

Save all the authoring changing for different audiences and click next.

image23

The target audiences and experiences are defined as we added in the Activities (can be modified if needed).

Click next.

image24

Define the duration and Priority and Save it.

We have successfully saved our activity and now we will get different personalized experiences for different audiences and seasons based on what we configured.

We can verify the targeting and personalization by viewing the page in the preview mode. On the top left corner we'll have the contextHub option available which will provide some contextHub features, using which we can verify the experiences that the particular audience/user will get along with the resolved segments.

image25

PERSONA - defines the user i.e., which user is logged in.

LOCATION - defines from what location that user is actually logging in from.

In our case, we can test the experiences by defining the persona.

Summer Female User:

image26

Summer Male User:

image27

So, we have verified the targeting and we are successfully able to get the personalized content based on the segments/audiences that we created.

Hope you find the blog insightful. Thanks!! 😄


Suchita Mishra | AEM Developer
LinkedIn Email