The latest release of Episerver A/B testing adds the ability to add custom goals for conversion. This post shows how it's possible to create a custom KPI that will trigger a conversion when a user matches a visitor group. 

How to implement a custom goal

Its possible to implement a custom goal by implenting the IKpi interface. The code below simply adds a Kpi once a user has matched a visitor group:

Once implemented you can select your custom goal in the coversion goal section of the A/B test UI:

Then its possible to select parameters for your goal:

Please note: The code above and the points below are based on the current released version (v1.0.5) and the A/B test functionality is still in beta. Episerver beta software means that the software is production ready, however it is subject to change outside the normal constraints of semantic versioning.

Points of interest in the implementation

  • Returning HTML as part of your implementation class never feels quite “right” to me. This is shown above in the UIMarkup and UIReadOnlyMarkup properties. However it is possible to use the UIMarkup attribute and set the configmarkup, readonlymarkup to separate the markup out of the class. If should be noted that the values for configmarkup and readonlymarkup are keys to embedded resources. This attribute also has text and description properties that can be used to set the name and description of the Kpi. It is however nice to be able to inject pure markup into the Episerver UI without using Dojo!
  • The IKpi.Validate method is used to validate the data for the Kpi before it is saved. It currently returns void which means the only way to inform a user that there is an issue with the data is to throw a KpiValidationException. Since it's basically a validation error I don't think its an exception and using a exception to handle it isn't necessarily an ideal scenario. Given the the A/B test functionality is still in beta this may change in future versions.
  • Once implemented the Evaluate method will be executed each time the event attached to in the EvaluateProxyEvent occurs for the content. In my example I've attached to the LoadedContent event meaning the Kpi will be assessed each time content is loaded so we can check if the user has matched the visitor group.

More information

Official documentation describing how to implement custom Kpis and also covers some of the elements above can be found here: http://world.episerver.com/documentation/developer-guides/CMS/key-performance-indicators-kpis/.

Conclusion

The new IKpi interface makes it easy to add to the built in Kpi's. It should be easy to build specific A/B tests meaning you can tailor your solution to each customer's business.


Comments