7

I am doing a POC for Personalization in DD4T, where I want to store the information of the Pages, and Components visited and to fill the Tracking_Keys table for a session user. I want to use this data to personalize the content.

I am using the below code to store the Keys

//For tracking the page and component visits           
var waiPage = new WAIPage(pgModel.Id, this.HttpContext.ApplicationInstance.Context); 
//For Storing the Tracking Key
Tridion.ContentDelivery.Web.WAI.TrackingKeys trackingKey = new TrackingKeys(waiPage.User);
trackingKey.IncrementKey(keyword);
trackingKey.SetKey(keyword, 8);
trackingKey.ExecuteUpdate();

The cd_wai_conf.xml is below here

 <?xml version="1.0" encoding="UTF-8"?>
  <Configuration Version="7.1"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="schemas/cd_wai_conf.xsd">  
<Global>    
</Global>  
<Presentations>   
<Presentation Id="1">     
  <Host Domain="localhost" Port="3035" Protocol="http" Path="/"/>      
  <Personalization Enabled="true" Persistence="cookies">       
    <Cookie Name="TDS1234" Expires="39000"/>
    <Tracking>          
      <Timeframe Type="hourly" Multiplier="1" Autofill="true"/>          
      <Pages Enabled="true"/>         
      <Components Enabled="true" Max="10" Averaging="true"/>         
      <ComponentLinks Enabled="true"/>
      <Keys Enabled="true" Increment="50" Decrement="1" Averaging="false" ComponentLinks="true"/>          
      <Exclude>            
        <Pages></Pages>            
        <Components/>           
        <Paths/>
      </Exclude>
    </Tracking>        
    <CustomerCharacteristics PreserveWhitespace="true"/>
  </Personalization>
</Presentation>
</Presentations>
</Configuration>

Also I have added the entry in to the cd_storage_config.xml

<ItemTypes defaultStorageId="defaultdb" cached="false">
  <Item typeMapping="Personalization" cached="false" storageId="defaultdb"/>
</ItemTypes>

With this configuration whenever I am requesting a page, the Page and the corresponding Component IDs are stored in the Page_visits and the Component_Visits table for the particular session user, and the Visit_Value column value increases with every page request. In the Tracking_Keys table the Keyword the value is stored as 400 for each keyword as I have set the Key as 8 and the Increment value as 50.

Is there any class or method to fetch this information [page visit/component visit value] from the Broker in DD4T?

Update 1:
In our case the tracking_key Value is not changing on the basis of page_visit/component_visit as the Increment(50) & the Key(8) values remain same.

So by using the code trackingKey.GetKey(keyCond.Keyword.Key) I am getting only 8]. To set the Key value as dynamic (using the Page_visit/component_visit value) , I need to read the Page_visit/component_visit value.

or is there any other way to handle this functionality?

2 Answers 2

4

@Manas, What I understand from your question is you are facing issue while incrementing the value of tracking key. To increment the tracking key value, you don't need to read the component visit/Page visit value. I can see some issue in your code, which seems to be a major issue in not updating the tracking key value. No need to use trackingKey.SetKey(keyword, 8);after trackingKey.IncrementKey(keyword);. So final code you can try is:

var waiPage = new WAIPage(pgModel.Id, this.HttpContext.ApplicationInstance.Context); 
//For Storing the Tracking Key
Tridion.ContentDelivery.Web.WAI.TrackingKeys trackingKey = new TrackingKeys(waiPage.User);
trackingKey.IncrementKey(keyword);
trackingKey.ExecuteUpdate();

Please share if this is not working for you..

1
  • Hi Mukesh, This one solved the issue. Now I can change the value of the Tracking_key
    – Manas.p
    Commented Jan 12, 2016 at 14:00
3

You can get the value using the following:

var waiPage = new WAIPage(pgModel.Id, this.HttpContext.ApplicationInstance.Context); 
//For Storing the Tracking Key
Tridion.ContentDelivery.Web.WAI.TrackingKeys trackingKey = new TrackingKeys(waiPage.User);

//retrieving cond from page.componentPresentation.Conditions 
if (cond is KeywordCondition)
{
    var keyCond = (KeywordCondition)cond;
    trackingKey.GetKey(keyCond.Keyword.Key); // getting key from the condition
}

There aren't any DD4T OOTB methods to achieve this.

you should add your publication id and host (you app url) in following

<Presentation Id="1">     
  <Host Domain="localhost" Port="3035" Protocol="http" Path="/"/>  
4
  • End to end example rajmittal.blogspot.in/2015/08/…
    – Aman
    Commented Jan 12, 2016 at 11:29
  • @aman this does not have details specially for tracking keys. this is pending from me.
    – Raj Kumar
    Commented Jan 12, 2016 at 11:30
  • @RajKumar : I have updated the question to pinpoint the exact problem.
    – Manas.p
    Commented Jan 12, 2016 at 12:13
  • I was able to find the documentation in OLD ContentDeliveryReferenceGuide_51SP4.pdf and SDL Tridion R5 Content Delivery Project Planning Guide 5.3 SP1_tcm89-17676.pdf and SDL Tridion R5 Templating Manual 5.3 SP1_tcm89-17683.pdf and tracking config of cd_wai.xml was also there.
    – Aman
    Commented Jan 12, 2016 at 12:16

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.