From 6cb6521b1698af517356989c1be2671d75407eeb Mon Sep 17 00:00:00 2001 From: James Marchant Date: Wed, 3 Feb 2016 11:39:22 +0000 Subject: [PATCH] Added in stats support --- optimizely.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/optimizely.php b/optimizely.php index c5d46cc..4e709f6 100644 --- a/optimizely.php +++ b/optimizely.php @@ -231,6 +231,24 @@ public function get_experiment_results( $experiment_id, $options = array() ) { ) ); }// end get_experiment_results + /** + * Get the top-level results (stats) of an experiment, including number of visitors, + * number of conversions, and chance to beat baseline for each variation. + */ + public function get_experiment_stats( $experiment_id, $options = array() ) { + // @TODO: support options + // @TODO: check for 503 in case this endpoint is overloaded (from docs) + $extra = ''; + if ( $options ) { + $extra = '?' . http_build_query( $options ); + }//end if + + return $this->request( array( + 'function' => 'experiments/' . abs( intval( $experiment_id ) ) . '/stats' . $extra, + 'method' => 'GET', + ) ); + }// end get_experiment_results + /** * Creates a new experiment */