AB test rule


Steps

Description

Remark

Setup environment

Create a plug-in project using the VS.NET extension template. Give it a name.

 

Find the sample code under “/extensions/ABTest”, uncomment the .cs code file and move it the file location you want.

Move the .cshtml file into the folder of “\Cms_Data\Views\ABRuleTemplates”. The .cshtml file name must match the RuleType property defined in above .cs file.

Development

Implementation
Inherits from CustomRuleBase and IVisitRule.
Implement the IsMatch method, return true or false to indicate whether the rule is matched or not.

 

Rule settings
You can define data model and template for your rule edit screen. It is the popup window to edit rule item value when you are adding a new rule item.
The template is the .cshtml file under “ABRuleTemplates” folder.
The data model can be defined in the same file as the IsMatch method, as seen in the example.

 

Data access
In the IsMatch method, you have access to all the Http Context and also your rule setting values.

 

Add an attribute to register your class in IOC
See example code for register into the IOC container

 

RuleTypeDisplayName
The Rule type name you see when adding a new AB test rule

 

Debug
You can directly develop and debug your AB test code within the VS.NET

Deployment

Build your project, get the generated dll and also the .cshtml file.
Go to the Kooboo instance you want to deploy to, place the dll in the bin folder and .cshtml file in the \Cms_Data\Views\ABRuleTemplates folder. You have done!