Skip to content

josecuellar/ABTestDotNetCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple AB Testing Engine for ASP .Net Core

Easy to use & easy to adapt to MVC

The repository contains two projects: Main library and demo project in ASP.net Core where you can see all configurations and all ABTest Engine functionalities

Configure your Expermients and Versions with percentage target in JSON File

Implement your custom repository for get & save experiments (DB, Memory, etc).

[
  {
    "Id": "8dcdcfa5-d6f4-42a0-9f53-08c7e9b3db93",
    "Title": "Experiment 1",
    "Versions": [
      {
        "KeyWord": "Version3",
        "Title": "title3",
        "Percentage": 60,
        "TimesSent": 0
      },
      {
        "KeyWord": "Version2",
        "Title": "title2",
        "Percentage": 20,
        "TimesSent": 0
      },
      {
        "KeyWord": "Version1",
        "Title": "title1",
        "Percentage": 20,
        "TimesSent": 0
      }
    ]
  },
  {
    "Id": "63899319-b0a0-4b00-b04c-60abb24152f2",
    "Title": "Experiment 2",
    "Versions": [
      {
        "KeyWord": "Version22",
        "Title": "title3",
        "Percentage": 75,
        "TimesSent": 0
      },
      {
        "KeyWord": "Version21",
        "Title": "title2",
        "Percentage": 25,
        "TimesSent": 0
      }
    ]
  },
  {
    "Id": "a55625a7-8816-40c9-805a-c77b4798d50d",
    "Title": "Experiment 3",
    "Versions": [
      {
        "KeyWord": "Version31",
        "Title": "title2",
        "Percentage": 50,
        "TimesSent": 0
      },
      {
        "KeyWord": "Version32",
        "Title": "title3",
        "Percentage": 50,
        "TimesSent": 0
      }
    ]
  }
]

Versions assigned to user using cookie by experiment

You can implement new providers for save to user assigned versions for each experiment

Use keywords version for tracking with analytics or other statistics frameworks for measure conversions

Configure Middleware in Startup.cs

Need manage Begin Request & End Request for all operations

app.UseMiddleware<Main.Middleware.ABTest>();

Configure Services Singleton in Startup.cs

Need manage dependency injection for manage operations in middleware

 
services.AddSingleton<IExperimentService, ExperimentService>();
services.AddSingleton<IExperimentRepository, JsonExperimentRepository>();

Configure Custom view names expander in Startup.cs

All versions have KeyWord for identify custom views. Engine try to get custom view for active experiment of assigned version. If not found, return default view.

For example: Partials/ListResults.cshtml | Partials/ListResults.KeyWord Version.cshtml

 
services.Configure<RazorViewEngineOptions>(options => {
   options.ViewLocationExpanders.Add(new ABTestViewLocationExpander());
});

Manage manually versions assigned

if (ABTestDotNetCore.Main.Middleware.ABTest.GetKeyWordVersionAssignedFromTitle("SolrVsSQL") == "SolrVersionKeyWord")
{
   <b>//To Solr</b>
}
else
{
   <b>//To Sql</b>
}

Take a look at demo project


alt text alt text alt text alt text


Feel free for fork and contribute!
Thanks!