Friday, January 23, 2015

Template Engines in Kenshoo

Recently we have begun re-engineering our RealTime Campaigns solution.
RealTime Campaigns (RTC) are an automated way for marketers to sync their product inventory with their online advertising. It works by taking a feed and applying some rules to create ads, keywords and any other search engine structure required.


For example:
Assume you have a feed of products and each product has a list of properties (e.g. short description, description, price, color, brand) the tool will allow you to create keywords using the template language. An advertiser will use the template engine to build from the list of the properties the keywords, text, and the ad headline 1, headline 2 and URL.


When designing the RTC engine we first needed to choose one of two classes of engines:
1. The logic-less template engines (e.g. Mustache)
2. The logic enabled template engines (e.g FreeMarker, Velocity)


After evaluating both options and validating the business requirements we decided to go with option 2 that will allow for creating templates that are based on the content of the feed items.


Then came the fun part of evaluating which engine should we work with.
We chose FreeMarker as it is the most mature, has a great set of string manipulation functions and is commonly used with other open source platforms we are using in house (e.g. Spring and DropWizard views templating).


We rolled out the new feature and it was well received in the field but there was one piece missing... Users wanted to test their templates. You would think that a tool for experimenting with templates already exists in the wild but after searching for an online simulator for Freemarker we found none. We therefore decided to write one - you can find our new simulator at freemarker-online.kenshoo.com. If you are interested in the code behind it or want to contribute to it, we have opened source it and the code can be found here.
Enjoy!