Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

@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..

share|improve this answer
    
Hi Mukesh, This one solved the issue. Now I can change the value of the Tracking_key – Manas.p Jan 12 at 14:00

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="/"/>  
share|improve this answer
    
End to end example rajmittal.blogspot.in/2015/08/… – Aman Jan 12 at 11:29
    
@aman this does not have details specially for tracking keys. this is pending from me. – Raj Kumar Jan 12 at 11:30
    
@RajKumar : I have updated the question to pinpoint the exact problem. – Manas.p Jan 12 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 Jan 12 at 12:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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