Coder Social home page Coder Social logo

ab_test's Introduction

/*
 * CakePHP A/B Test Plugin
 * Copyright (c) 2011 Matt Curry
 * www.PseudoCoder.com
 * http://github.com/mcurry/ab_test
 *
 * @author      Matt Curry <[email protected]>
 * @license     MIT
 *
 */

/* Description */
A plugin to for doing A/B and Multivariate testing in CakePHP apps.  Tested on CakePHP 1.3.7

/* Instructions */
 1. Download the plugin to app/plugins/ab_test.
 2. Run /ab_test/config/sql ab_test.sql to create the database tables.
 3. Include the component in your controller (this will also include the helper automatically):
		var $components = array('AbTest.AbTest');
 4. Define your tests in bootstrap.php
		Configure::write('AbTest', array('test-name' => array('options' => array('new' => true, 'returning' => true),
																													'variates' => array('option-name-1', 'option-name-2'))));
 5. Create elements for each of the variates in /app/views/elements/ab_tests/test-name
		For example using the test defined in step 4 your should have 2 files:
		/app/views/elements/ab_tests/test-name/option-name-1.ctp
		/app/views/elements/ab_tests/test-name/option-name-2.ctp
 6. In your view, where the test option will appear:
		<?php echo $abTest->render('test-name'); ?>
		This will render either option-name-1.ctp or option-name-2.ctp in that spot.
		The options are shown evenly and a cookie is set, so that returning users will see the same one.
 7. When a "conversion" happens track it with:
		$this->AbTest->conversion('test-name');
		For example you could put this in your controller after a successful signup.

/* Test Results */
	There is no "admin" for this plugin.  The DB schema is pretty simple and you could easily open up your favorite DB client and see the results.
	OR
	Install the CakePHP Status Plugin (http://github.com/mcurry/status) and include the panel:
	Configure::write('Status.panels', array('AbTest.stats'));
 

/* Advanced */
 1. Which option the user is shown may affect how the user is handled.  For example if you split test two different prices you want to make sure to charge them the right price.  In your controller call $this->AbTest->variate('test-name'); and it will return the option-name for that user.  For example:
	 switch($this->AbTest->variate('price-test')) {
		default:
		case 'year-15':
		 $price = 15;
		case 'year-20':
		 $price = 20;
	 }
 2. There is no limit to the number of tests/options.  Create as many elements as you'd like and add the names to the array in bootstrap.php.
		Configure::write('AbTest', array('test-name-1' => array('variates' => array('option-name-1-1', 'option-name-1-2'))),
															 array('test-name-2' => array('variates' => array('option-name-2-1', 'option-name-2-2', 'option-name-2-3', 'option-name-2-4'))));

ab_test's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.