Code Monkey home page Code Monkey logo

cheeztest's Introduction

  ______   __                 ________           __     
 /      \ /  |               /        |         /  |    
/$$$$$$  |$$ |____   ________$$$$$$$$/_______  _$$ |_   
$$ |  $$/ $$      \ /        |  $$ | /       |/ $$   |  
$$ |      $$$$$$$  |$$$$$$$$/   $$ |/$$$$$$$/ $$$$$$/   
$$ |   __ $$ |  $$ |  /  $$/    $$ |$$      \   $$ | __ 
$$ \__/  |$$ |  $$ | /$$$$/__   $$ | $$$$$$  |  $$ |/  |
$$    $$/ $$ |  $$ |/$$      |  $$ |/     $$/   $$  $$/ 
 $$$$$$/  $$/   $$/ $$$$$$$$/   $$/ $$$$$$$/     $$$$/  

CheezTest lets you create and run Batcache-compatible server-side A/B tests in your theme.

A joint LOL by the fine folks I Can Has Cheezburger (http://www.cheezburger.com) and Automattic (http://automattic.com)

Main class from which all A/B tests are inherited. Enables fast setup
of A/B tests - upon initialization, the basic order of execution is:
set test name > check if user is qualified to participate > check
if user has been assigned a segment, and assign if not > assign user
to group > execute 'action' callback if present.

User's qualification, segment, and group tests are done in batcache
so as to ensure correct cache variants are served.

User's segment is assigned server-side via magic. Mutliple test
segments are assigned at once - so if a user is qualified to participate
in more than one test, all segments are assigned at the same time. When
segments need to be set, a small javascript is injected into the <head>
via a call to CheezTest::write_segment_cookie(). This javascript
sets a cookie to retain the segment assigned earlier.

Test case data (name, is_qualified, & group) are stored in the $active_tests
static hash and made accessible via the 'is_qualified_for', 'get_group_for', and
'is_in_group' static methods. This enables theme branching via:

if ( CheezTest::is_qualified_for( 'my-example-test' ) {
    //test-specific stuff goes here
}

- or -

if ( CheezTest::is_in_group( 'my-example-test', 'my-example-group' ) ) {
   //group-specific stuff goes here
}

The plugin makes use of Batcache’s support for vary_cache_on_function, which saves page variants in a page’s cache and then evaluates which one to serve when the page loads.

IMPORTANT: Since the tests run before Batcache, which in turn runs very early (before theme code is included), only built-in PHP functions and jetpack_is_mobile() can be used when defining tests. Any theme-specific functions will not be available.

cheeztest's People

Contributors

bbrooks avatar busticated avatar chriszarate avatar lomeraniel avatar mjangda avatar trepmal avatar yolih avatar

Stargazers

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

Watchers

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

cheeztest's Issues

run_user_segmentation runs after analytics JS

Because you're hooking CheezTest::run_user_segmentation() into 'wp_head' instead of 'wp_enqueue_scripts', the user segmentation JS is printed after all the JS that's enqueued with the standard WordPress api.

First of all, seems like a waste to start downloading and running a bunch of external scripts and THEN reload the page.

Second of all, on our site it ended up causing an artificial doubling of pageviews in Google Analytics. For each new users, all of our analytics JS would run, then the cheeztest segmentation would assign a cookie and reload the page. Analytics would run again.

We solved this by removing the action from wp_head and manually calling it right before our analytics JS.

I am curious if this was a conscious decision or just an oversight? Or am I missing a good reason to keep the segmentation JS at the bottom of the head?

Cheers,
-Ben

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.