Expand my Community achievements bar.

SOLVED

Showing Campaigns/Promotions based on User's group in AEM

Avatar

Level 2

How to add a new trait in Segmentation for my teaser such that teaser will be shown to specific User's group ,   and also Is there any way to execute java code as part of segmentation.

Some one please help on this.

Regards,

Madhav

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can customize a component that is used with segmentation to call a Java class that is bundled in an OSGi service. Like all AEM components -- they can be customized to meet your requirements. 

View solution in original post

9 Replies

Avatar

Correct answer by
Level 10

You can customize a component that is used with segmentation to call a Java class that is bundled in an OSGi service. Like all AEM components -- they can be customized to meet your requirements. 

Avatar

Level 8

I'm not sure about the Segmentation, but there does not seem to be an out-of-the-box way to define a segment based on user group. I suppose  you could add the information to the client context [0] when the user logs in, and then use the Generic Store Property to access it in the segment [1].

For executing java based on segment, the Target component does that for content components. [2]

 

scott

[0] http://dev.day.com/docs/en/cq/current/developing/client_context_detail.html

[1] https://dev.day.com/docs/en/cq/current/administering/segmentation.html

[2] http://dev.day.com/docs/en/cq/current/wcm/content-targeting.html

Avatar

Level 2

Thanks. Can you please provide some more info on this. Actually we need to show different promotions to different groups based on logged in user .

Please provide any insight on this.

Avatar

Level 1

We need to show promotions based on user groups.
The client context was customised to add a custom property and then used the Generic Store Property to access it in the segment.
The newly added custom property, gets loaded as expected in the client context.
But on the initial load of the client context, the teaser segment is not resolved correctly (With the custom attribute value).
Once some changes are done in the client context, the teaser segment gets resolved correctly.
Are some configuration changes required so that the teaser segment gets resolved correcly on the initial load.
Please provide an idea on this regard.
Highly appreciate if we could get any other approach to show promotions based on user groups.

Avatar

Level 2

Thanks, Scott.  i ll try that.

One small question whenever open client context ,it is not showing logged in user's data after manually load context then only showing. Please give any idea on this.

Avatar

Level 2

smacdonald2008 wrote...

You can customize a component that is used with segmentation to call a Java class that is bundled in an OSGi service. Like all AEM components -- they can be customized to meet your requirements. 

 

I have added new property (role) in trait.jsp like gender..etc and configured segmentation, campaigns. can I know detailed changes need to be done(customization of personalization/clientstores/profiledata/init.js.jsp) for loading specific teaser for specific role in AEM 5.6.

Avatar

Level 2

Manjunath DJ wrote...

smacdonald2008 wrote...

You can customize a component that is used with segmentation to call a Java class that is bundled in an OSGi service. Like all AEM components -- they can be customized to meet your requirements. 

 

I have added new property (role) in trait.jsp like gender..etc and configured segmentation, campaigns. can I know detailed changes need to be done(customization of personalization/clientstores/profiledata/init.js.jsp) for loading specific teaser for specific role in AEM 5.6.

 

Hi smac thanks for your reply.

I am successfully able to load teaser based on role with customization of personalization/clientstores/profiledata/init.js.jsp.

but still am facing below issue kindly please help me out on this:

 I am trying to customize teaser.jsp which can read multiple campaign path from page property instead of single campaign path. 

 JSONObject teaserInfo = targetedContentManager.getTeaserInfo(resourceResolver, campaignPath, location);

here am passing different campaignPath by looping length of campagin path which i get from page property.

 am able to pass the value of "allTeasers" to initializeTeaserLoader

 initializeTeaserLoader(<%=allTeasers%>, "<%=strategy%>", "<%=targetDivId%>", "<%=(WCMMode.fromRequest(request) == WCMMode.EDIT)%>", "<%=trackingURLStr%>", "<%=resource.getPath()%>");

but when am loding a page with teaser and teaser's component is loading but with embeded style "display:none"(html markup teaser is attached)

in web -page console am getting following error:

  1. Uncaught SyntaxError: Unexpected end of inputjquery.js:564
    1. (anonymous function)jquery.js:564
    2. jQuery.extend.globalEvaljquery.js:565
    3. (anonymous function)jquery.js:5868
    4. jQuery.extend.eachjquery.js:611
    5. jQuery.fn.extend.domManipjquery.js:5853
    6. jQuery.fn.extend.appendjquery.js:5626
    7. showTeaserkernel.js:395
    8. handleTeaserkernel.js:419
    9. (anonymous function)kernel.js:465
    10. _g.$.ajax.completeshared.js:180
    11. firejquery.js:974
    12. self.fireWithjquery.js:1082
    13. donejquery.js:7665
    14. callback

 

Here i found that normal components like text/text image are rendering correct teasers resolving segments when page is loading but if customized components which have ajax call are not working(am getting above error) but still i can see html markup teaser is attached. i am using jquery version 1.8.2 .not sure whats happening with /libs/cq/personalization js

Avatar

Level 8

I never noticed that myself, until now  :)

I am trying to find an answer for you.

 

scott

Avatar

Level 2

i was able to resolve this issue" EOF error" component level js had comments "//comments" which were not readable by teaser.js and it was blocking the execution.