Overview

Introduction

Experiments.js is an optional JavaScript package that allows developers to easily A/B test Smart Cart, Widgets, and settings, using your favorite testing suites like Google Optimize, VWO, Optimizely, or your own solution. It is extremely lightweight (under 2kB) with zero dependencies.

To use the package, install the script in your theme's head before the closing tag </head>:

<script src="https://cdn.rebuyengine.com/onsite/js/experiments.js"></script>

Please note that you should NOT use defer or async, which allows the script to load and be ready for use before the DOM content is loaded. The script is loaded from a CDN, so download times are typically below 40ms.

Once Experiments.js is included, the package becomes globally available at window.RebuyExperiments. You can now easily use your optimization platform to run experiments!

Typically Smart Cart or the Widget being experimented on are installed to the theme with Live Mode disabled. You can then use RebuyExperiments to enable the widget only for a certain segment of your traffic. In addition, you can apply settings changes via an experiment to test discount amounts, language changes, different API endpoints, or any other configuration -- it's totally hackable and totally up to you!