Monday, September 7, 2015

Content targeting based on clickstream

Every online shopping store has a feature where consumers are shown related items or recommended items as any registered or anonymous users keep on browsing certain items on a website. Such use case are very common and can be developed within WCS or FatWire using Engage.

I am describing a very simple use case using Oracle WCS 11g 11.1.1.6.1 JSK for avisports site. My aim is to record number of times any article (article can be of any type: Running, Football, Skiiing, etc.) was clicked on a particular section and show recommended articles in "you may also like" section on basis of number of clicks + article type.

 Solution can be broken into following steps:
  • Enable visitor attribute, history attribute, history definition, segment and recommendation asset type for AviSport site
  • Add all the required start menus
  • Create visitor attribute - aviarticleuser (string, length-20)
  • Create history attributes - AviArticleType (enumeration - with all the values of ArticleCategory attribute: Category) and AviArticleClickCount (integer)
  • Create one history definition - AviArticleHistory (include AviArticleType and AviArticleClickCount)
  • Create segments for each article category or just create for 2 article category with condition aviarticleuser=<articlecategoryname> (For eg: for baseball segment, add the visitor attribute condtion as aviarticleuser=Baseball and for history definition condition, include count >10 and select "Baseball" as AviArticleType)
  • Create one recommendation asset (mode: recommendation, for asset type: article and select all segments and include corresponding articles and also select some articles for default case)
  • Record anonymous or visitor's clicks at particular section only.
  • Update ArticleLayout to calculate segments and show related articles based on recommendations.

First 7 steps, should be very straightforward. Full details on creating and configuring them is already given in developer's guide.

For recording visitor's click on particular section, I have added one param to Summary/Link (engage = yes) as I would be targeting those visitors who click on Related links section's articles only on any article detail page. Then, add engage parameter to avisports/AVIArticle/GetLink. On clicking article link of related links section, will add one param: engage to the output url, so add that param to ArticleLayout and ArticleLayout2 templates in cache criteria.

Now, update both article layout template to call the element: avisports/getVisitorArticles. This element finds the category of the current article (using query),  then finds the history count (vdm:gethistorycount), records the current article (vdm:recordhistory) to history definition, sets scalar values (vdm:setscalar) which helps while calculating segments, calculates segments (commercecontext:calculatesegments) and then loads list of articles from via recommendation asset (commercecontext:getrecommendations). This whole process of how segments are calculated and recommendations work is well explained in detail in developer's guide.

Futher improvements can be done by calculating segments for the visitor and then calling the template by including the segment id in cache criteria and then loading list of assets from recommendations.

As history definition table is created separately and keeps on adding data exponentially as visitors browse your site, it is better to clean data from this table on timely basis which is explained on my other post: Flushing visitor's data

All the updated elements are bundled here for downloading. I hope this post helps many developers.

Further improvements can be done by using the tag: <commercecontext:setsegments> if you know what segment does a visitor belongs to and then, can add the segment id to cache criteria to leverage the use of OOTB caching of Sites. Discussion on setting segment prior to calculating recommendation is succinctly explained here.

Disclaimer: Any sample code on this blog is not officially recommended, use at your own risk.

No comments:

Post a Comment

A simple code compare functionality

One of the most important aspect of any development cycle is deployment and while deployment, it is very important to note the changes don...