August 08, 2015

Profiling and Personalization using Target Groups in DXA DD4T

Profiling and Personalization aka P&P is very useful feature of Tridion. User's behavior can be tracked and user can be targeted with set of content.

In this post i am going to detail P&P custom characteristics use with DXA and DD4T. We started with SmartTarget evaluation but due to license cost and hardware requirement for Fredhopper caused us to evaluate this Out of the box feature of Tridion to use with DXA.

P&P provides basic but very useful personalization features. 
  1. Tracking Keys
  2. Custom Characteristics
Tracking Keys: Tracking keys are used for Implicit Personalization. Using these  you can can track interest as user visits various content. This functionality works on the tridion Category/keywords. Editor add the "Activate tracking" tbb  in the page template and add the category for tracking in CT's Tracked Category.  Schema should also be added to the component also. publish the page.
On your presentation side custom code has to be written using WAI to track the activities. 

Custom Characteristics:  CC are  used for Explicit Personalization. User information for targeting can be collected using some form e.g. gender, age, city, country. This information can be persisted in the broker db for further use.

Steps to use CC

Page Template Change

Include dd4t tbb "Add Target Groups" on the page template.

Define TargetGroup : 
  • Right click on folder and select  TargetGroup.
  • Set the characteristics as shown below.














  • TargetGroup can only be assigned to component Presentations. Lets do it & Publish the page.









XML: 
After publishing page, DD4T page xml will contain Condition need under Component-presentation node.

<Page>
.
.
 <ComponentPresentation>
.
<Conditions>
        <Condition d5p1:type="CustomerCharacteristicCondition" xmlns:d5p1="http://www.w3.org/2001/XMLSchema-instance">
          <Negate>false</Negate>
          <Name>city</Name>
          <Operator>Contains</Operator>
          <Value xmlns:q3="http://www.w3.org/2001/XMLSchema" d5p1:type="q3:string">Mumbai</Value>
        </Condition>
        <Condition d5p1:type="CustomerCharacteristicCondition" xmlns:d5p1="http://www.w3.org/2001/XMLSchema-instance">
          <Negate>false</Negate>
          <Name>city</Name>
          <Operator>Contains</Operator>
          <Value xmlns:q4="http://www.w3.org/2001/XMLSchema" d5p1:type="q4:string">Delhi</Value>
        </Condition>
      </Conditions>
    </ComponentPresentation>
.
.
</Page>

Presentation server

Here XML is de-serialized to c# object
Note: Current DD4T 1.31 which is part of latest  DXA has bug , because of that XML-with- -conditions-tag de-serialization fails.
As this is fixed in DD4T 2.0 so i used some code from 2.0 version and fixed it.

When user access the website where we have WAI module configured
  • Cookie is generated with USER_ID key. 
  • If you have non-login website this USER_ID is generated automatically by WAI
  • You can write custom logic to update the USER_ID with your website user_id
There is no OOTB code to work on Conditions on DXA/DD4T, so you have to write custom code to remove the component presentation where condition fails.

Example user is not from Delhi or Mumbai. then delete that component presentation. 

 var  waiPage= new WAIPage(page.Id, this.HttpContext.ApplicationInstance.Context);
            CustomerCharacteristics cc= new CustomerCharacteristics(waiPage.User);
            var city= customerCharacteristics.GetValue("city");
            if (string.IsNullOrEmpty(city))
            {
                cc.SetValue("country", "Kolkata");//this city may come from your Geolocation module.

                cc.ExecuteUpdate();
            }                                                                       
           foreach(var cp in page)
            {
                foreach(var condition in cp.Conditions)
                {
                    if (condition is CustomerCharacteristicCondition)
                    {
                        
                        var ccCondition= (CustomerCharacteristicCondition)condition;
                        var node = (XmlNode[])ccCondition.Value;
                        string city= node[2].Value;       
                                    }
//now you can remove the component presentation here whereever conditions does not match.

                }
            }

now updated page is processed further via DXA for generation of views


June 30, 2015

DXA aka STRI - My Tiny step in Tridion (SDL Web) Reference implementation.

What is in name? as told by a Great Author and a famous community Builder

STRI - SDL Tridion Reference Implementation: Tridion development is usually considered complex and time consuming, also there is learning curve understanding bits any bytes of it. so few Tridion MVPs came together and developed this MVC based solution to make Tridion development bit easy and fast. STRI provides lots of modules out of the box,  which  are usually required for most of the sites.

In under-hood it uses DD4T as default, but you can extend and create your own custom framework if any and use it instead. so all the template work which usually take more time, which includes DWT/Razor, C# tbbs etc, can be developed in MVC with ease.

DXA - Everything is same just a rename. so new name is Digital Experience Accelerator

Each individual community framework and modules,used in DXA, should be supported by their respective owner or community (wherever applicable.)

Note: You might be thinking its just an DD4T. as i mentioned above  DD4T is just another module in DXA, but yes big module along with other useful modules and features e.g
  1. Google Analytics
  2. Solr Search using SI4T framework
  3. Language Selector
  4. XPM Ready, Yes your site is XPM ready from start, no longer  phase 2 stuff now :)
  5. Navigation and breadcrumbs
  6. Image Resizing
  7. Responsive Design using bootstrap

...Many more...

sample site comes with lots of modules integrated for reference. just install and diggit.

Download DXA/STRI

December 31, 2014

Different API and Extension points in Tridion CM

Sdl Tridion can be customized at various levels as it provides very rich APIs to extend it. Tridion has different extension points for CM and CD. i will try to cover maximum extension points below.

Content Management

APIs

1) Tom.net: Tom.net is .net based API, it runs and CM machine. it allows to you to interact from CM machine only.  Tom.net provides various methods to be used for Templating, Event System. This is Read/Write API, but write operations are by default off in config.

2) Core Service - Core service is WCF service which expose various APIs to interact with CM system. it provide CRUD methods to operate on various CMS Objects. Main use-case of core-service is when you need to interact with CM machine from different machine other than CM or if you want to integrated CM with some third party system. It was introduced in Tridion 2011 (to replace existing COM based APIs) and still in use. It is also used in Workflows
e.g:  you need to read some Xml and create components in Tridion CM.

3) Anguilla: It is used to extend Content Manager Explorer(CME) user interface. eg. you want to introduce new buttons and new functionality in CME. e.g Custom spell checker, custom publishing, extend paste functionality. It was introduced in Tridion 2011 and still in use.

4) ECL : External Content Library was introduced in Tridion 2013, its very useful and awesome API available in Tridion. It allows to list/integrate external content repositories  third-party content/media in CMS and allow you to use it as native components with little exception. The access point looks just like a normal folder, making it easy to manage.
e.g . User want to see all images of DAM into CM system, want to view You tube or Dailymotion videos in CM interface to use in the components. 

Extension Points:

5) GUI Extensions - Its used to extend/customized the CMS UI. anguilla, JS and .net are used to create a GUI extension.

6) Events: Tridion provides Events as extension point where you can capture particular event and provide some customization. one of the most used use-case is validation of data. so when user save the component, save even can be captured and validate the data, log the data etc.

7) Custom Resolver: A resolver basically read an item from the publishing-queue and returns a list of items to be rendered. Tridion has kept it extensible so if you want to override default resolving behavior.
e.g when a component is resolved, by default all the component that links to this component are also resolved and so on. so it gives very long queue and impact the performance also, so if you want to resolve only this component or level 1 component this can be extended and registered in the TridionContentManager.config file.

8) Custom Page: Custom Pages can be used to perform operations in the Content Manager that are not supported by the default UI(user interface) . e.g, create a Custom Page that talks with the Core Service to automate Page creation. it can also be used to customize dashboard for users.

December 16, 2014

Anchor in Tridion Component links

In Tridion Link Anchor (jump to specific section of the page) is very tricky. there is an out of the box anchor option. let discuss that first.

Anchor OOTB : In component link there is an attribute "Add Anchor"

<tridion:ComponentLink runat="server" PageURI="tcm:85-159563-64" ComponentURI="tcm:85-159309" TemplateURI="tcm:0-0-0" AddAnchor="true" LinkText="internal link test" LinkAttributes=" title= &#34;alt text for link &#34;" TextOnFail="true"/>

when this AddAnchor = true is set. Tridion CD will create anchor for particular components as per their position of the page.

e.g following is a Tridion page sompage.aspx having three components Comp 1 and Comp 2 and Comp 3

------------
Comp 1
---------
Comp 2
---------
Comp 3
---------------

e.g you use comp2 as component link on another page. it will be resolved as somepage.aspx#1
so this is as per the position of the component on page.

another catch is you have to create <a id="1"> on somePage explicitly using your templates. this is not automated.

Custom solution:
As OOTB solution is base on numbers only. if you want to based it on some text e.g #Intro. you need some customization for it.

I have develop & tested this small solution for it.
------------------------------------------------------------------------------------------------------------
namespace  CD.Web.ComponentLink.Extensions
{
    public class ComponentLink : Tridion.ContentDelivery.Web.UI.ComponentLink
    {
        [DefaultValue("None")]
        [Bindable(true)]
        [Category("Appearance")]
        public string AnchorName { get; set; }


        protected override void Render(HtmlTextWriter writer)
        {
            if (HttpContext.Current == null || HttpContext.Current.Application == null)
                return;
            using (var compLink = new Tridion.ContentDelivery.Web.Linking.ComponentLink(new TcmUri(ComponentUri).PublicationId))
            {
             
                var link = compLink.GetLink(PageUri, ComponentUri, TemplateUri, LinkAttributes, LinkText, TextOnFail, AddAnchor);
                link.Anchor = AnchorName;
             
                string linkAsString = link.ToString();
                writer.Write(linkAsString);
                this.RenderChildren(writer);
            }
        }

    }

}
------------------------------------------------------------------------------------------------------


  • Register above custom control in your website's web.config 
  • Update schema to accept the Anchor from Editor
  • Update template code to pass this anchor name as mention below

<Rk:ComponentLink runat="server" PageURI="tcm:85-159563-64" ComponentURI="tcm:85-159309" TemplateURI="tcm:0-0-0" AnchorName="true" AddAnchor="false" LinkText="internal link test" LinkAttributes=" title= &#34;alt text for link &#34;" TextOnFail="true"/>

do post comments if you have any questions.