2

I have implemented a Web site by using DD4T Java version 2.0.

I'd like to implement Profiling and Personalisation, which uses Target group.
First I made a Target Group, and add it to a component presentation on a page. Then adding a TBB Add Target Groups to page template and run it on Template Builder, following element is added to JSON.

"Conditions": [
    {
        "Name": "key", 
        "Negate": false, 
        "Operator": 4, 
        "Value": "value"
    }

While using DD4T Java, org.dd4t.contentmodel.ComponentPresentation does not have property corresponds with target group Condition, so I cannot get target group's condition.

My questions are following.

  1. Is it possible to do Personalization with target group on DD4T Java 2.0?
  2. If it's possible, is there any documentation?
  3. Does anyone know how to do it?

Regards,

1
  • 2
    I am happy to add that in 2.0.5 of dd4t-java. The main reason its not in there is because we only recently got full ComponentPresentation JSon as data structure. 2.0.5 is expected to release third week of April. So, can you either raise an issue @ Github or fix it and do a pull request? Thanks!
    – Raimond
    Commented Mar 22, 2016 at 8:55

2 Answers 2

2

Yes, its possible but there is no OOTB code in DD4T handling Condition Tags. You will get the condition list in your component object.

But after that You have to write your own code to handle it as per your requirements i.e. what component you want to remove or show from your current list of presentation according to your conditions.

Reference from my blog but it is in c# & will give you hint how to implement.

Update: as mentioned by Raimond above, de-serialization part is due in April.

2
  • 1
    Thanks, but your blog seems to mention about .NET. I'm using Java, and Java's ComponentPresentation and Component class doesn't have property like "Conditions". Commented Mar 22, 2016 at 4:39
  • In your blog, getting cp by "foreach(var cp in page)". I guess this "page" is DD4T's page object which is de-serialized from XML, and "cp.Conditions" is de-serialized too. But in Java, I cannot find any property corresponding with "cp.Conditions". If so, it means target group's condition is not de-serialized to Java object, and it's impossible to get condition by Java. Commented Mar 22, 2016 at 6:00
1

Below are few links which will be usefull:-

profiling-and-personalization-without-dcp-and-tracking-keys

Target Groups based Contenttarget-groups-based-content

I did for Java but not DD4T version, If you are able to generate the condition then Set up WAI API as per the blog given by Raj Kumar and try with the below code.

<%@ taglib uri="cd_tags" prefix="tridion" %>
<%@ page import="com.tridion.web.jsp.JSPPage,
com.tridion.personalization.CustomerCharacteristics,
com.tridion.user.User"%>

<%
JSPPage waiPage = new JSPPage(pageContext, "tcm:1-161-64");
CustomerCharacteristics customerCharacteristics = new CustomerCharacteristics(waiPage.getUser());
String custT = (String)session.getAttribute("customerType");
customerCharacteristics.setValue("customerType", custT);
customerCharacteristics.executeUpdate();
%> 

If using MVC then these API can be used in controller as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.