Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

AEM's preview mode for Campaign users and targeted contents


Level 3


I've followed the steps on https://docs.adobe.com/docs/en/aem/6-2/author/personalization/adobe-campaign/target-adobe-campaign.h... to setup targeted contents for campaign segments.

However, when previewing the page by selecting a persona that is linked with Adobe Campaign (seed addresses), the personalization properties (e.g. firstname, lastname) are displayed properly, but the targeted sections show the default contents, altough targetData.segmentCode comes from Campaign as expected and matches the rule setup in the campaign trait.

The targeted contents appear in the emails generated by the Campaign delivery as expected. So the only thing that doesn't work is the preview in AEM.

Has anybody setup preview for targeted contents with Campaign users already?


10 Replies


Level 2

Hi, Kornel. How are you?

Kornel, I was able to make the preview mode work by following the steps described here:

Personalization in AEM 6.2

But I was using ContextHub as engine instead of Adobe Target or Client Context and the segments for ContextHub are different from the segments for Client Context (as far as I've understood, we can't mix them).




Level 3

Thanks for your replies! My investigation so far shows that only the "Segment ID trait" from the "Segmentation - Adobe Campaign" component group will result in such segment that will work properly during the targeting in a targeted Adobe Campaign delivery. However segments built with this one won't be resolved in preview mode on the touch UI using persona from the context hub. So it seems that either I have working preview in AEM (Contexthub+TouchUI) or working targeting in Campaign, but not both. This is not a blocker, as I can preview the targeted contents in targeting mode, but would be nice to make it working on the touch UI and contexthub segments. Maybe in 6.3?


Level 4

Hi, Kornel.

By reviewing our conversation, I think I got the wrong end of the sticky...

I was able to use both Targeting mode and Preview Mode (ContextHub + Touch UI) in AEM 6.2 even for regular components, such as the text component and the title component.

Targeting those components will generate some page "fragments" (I don't recall the correct name for this type structure/component) under the corresponding Campaign, containing the value set for each selected segment.

What kind of issues have you been facing?

Has your Campaign been set to use ContextHub?

Have your segments been created as ContextHub Segments instead of "regular" (Client Context) segments?

Do your page templates/components include the context hub client library (it's a cq:include in the pages)?




Level 3

Hi Daniel,

Thank you for your reply!

Regarding your question: I've created "regular" Client Context segments by following this guide: https://docs.adobe.com/docs/en/aem/6-2/author/personalization/adobe-campaign/target-adobe-campaign.h... Segments, but I'm trying to preview this on the Context hub.

The segment and trait in the article are designed to work with Adobe Campaign (another product in the marketing cloud). The trait in such segment tests a property (targetData.segmentCode), which is populated by Adobe Campaign during email delivery. It all works well when synchronizing the page (email template) into Adobe Campaign and delivering the email, but on AEM side targetData.segmentCode is not available in the preview mode, but it is wrapped into an object called seedData. Based on this I think I could workaround the issue and find a solution that makes both Adobe Campaign and AEM's client context happy.




Level 2

I've done the same using the default ContextHub and can preview the experience on Author, but nothing on Pubish. No even the default value of the targeted component. What am i missing?


Level 3


There can be many reasons preventing it from working properly. Try to collect symptoms and details by checking the following:

1. Are the author/publish in sync? Have you published everything properly? Check not just the page content node, but any related nodes under e.g. /etc, /content/campaigns, /content/dam, ...

2. Does the content display on the publish before transforming it to targeted content?

3. Are there any errors on the browser console?

4. Check the network activity on page load. Is there a request issued by the browser to get the content for the targeted area? If yes, what is the response?

5. Is there anything related in the error log?


Level 2

Thanks for the checkpoints.

1. Yes

2. The targeted content data does not show up on publisher if it is targeted. Not even the default experience

3. No

4. Screenshot below

Screen Shot 2017-06-26 at 11.09.49 PM.png

5. Do not see any specific.

Also observed this on the page source:

If we look at the page source, we see the below. "campaignName" is empty?

<div class="target parbase">

    <script type="text/javascript">

        if (window.ContextHub && ContextHub.SegmentEngine) {

            ContextHubJQ(function() {


                    locationId: '_content_brand_en-us_comms_jcr_content_searchpar_title_631229628',

                    variants: [{"path":"/content/brand/en-us/comms/default","name":"default","title":"Default","campaignName":"","thumbnail":"/content/brand/en-us/comms.thumb.png","url":"/content/brand/en-us/comms/_jcr_content/searchpar/title_631229628.default.html","tags":[]}],

                    strategy: 'first',

                    trackingURL: null





    <div id="_content_brand_en-us_comms_jcr_content_searchpar_title_631229628" class="campaign ">

      <noscript><div class="default title">

      <div class="ups-title">

        <h1 class="title-text">Default Title</h1>





Here's a summary of the issue:



Level 4

Hi, konathalasuren.

You can try a few things:

1. Using the JavaScript console, add a breakpoint to "if (window.ContextHub && ContextHub.SegmentEngine) {" and reload the page

If the if body doesn't get called, the include of the contexthub JS library is probably at the wrong place.

Move it to the <head> of the page.

2. Using the JavaScript console, open contexthub.kernel.js, add a breakpoint to the second occurrence of "return resolvedSegments" and reload the page

At the first time, the resolvedSegments will be empty. Click on continue.

At the second time, inspect the resolveSegments object. Your custom segment(s) should be there.

Another way of checking this is by enabling debug and disabling silent mode of the ContextHub framework on your publish instance, but this is very verbose.

If your segment(s) is(are) not there:

  1. open it(them) for edition and check its(their) rules;
  2. try to replicate/activate it(them).

3. Check if the "master area" of your campaign is active/published

The master area is the parent page of your campaign. For some reason, the master area appears only in the classic UI:






Level 2

1. Body does get called

2. contexthub.kernel.js does not show up in the list of js files.

3. Yes, master area of campaign is published


1. On Publish I do not see the new audiences we created under /etc/segmentation/contexthub . I can see them on Author.

2. Changed the code to include contexthub in our head.html as below:

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

Earlier we used to have the below:

<sly data-sly-test="${!wcmmode.disabled}">

        <div data-sly-call="${clientLib.all @ categories='personalization.kernel'}" data-sly-unwrap></div>

        <div data-sly-resource="${'config' @ resourceType='cq/personalization/components/clientcontext_optimized/config'}" data-sly-unwrap></div>

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


    <sly data-sly-test="${!wcmmode.disabled}">

        <div data-sly-include="/libs/cq/cloudserviceconfigs/components/servicelibs/servicelibs.jsp" data-sly-unwrap></div>

        <meta data-sly-call="${clientLib.all @ categories='cq.apps.targeting'}" data-sly-unwrap></meta>