Elevate AB Testing with window.dfc

Getting Started

Installation: Copy the following script tag into your <head>:

javascript
<script data-docs="https://digitalfuelcapital.pages.dev/dfc.inline.js">"use strict";!function(){var a,h,s="dfc-exp-";try{var t=new URLSearchParams(location.search),o=new RegExp("^".concat(s));t.forEach(function(t,r){o.test(r)&&localStorage.setItem(r,t)})}catch(t){console.error(t)}window.dfc||(t=window.dfc=function(r){var t,o,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2;try{var e="".concat(s).concat(r),n=parseInt((o=localStorage.getItem(e))||(o=c-1,t=Math.ceil(0),o=Math.floor(o),Math.floor(Math.random()*(o-t+1))+t),10);localStorage.setItem(e,n),a.push([r,n]);try{h.forEach(function(t){return t(r,n)})}catch(t){console.error(t)}return n}catch(t){return 0}},a=t.experiments=[],h=t.trackers=[],t.onExp=function(r){a.forEach(function(t){return r(t[0],t[1])}),h.push(r)},t.version="2023-02")}();</script>

The un-minified version is Long Form: here

Helper Function

Examples of experiments and helper functions: dfc.v2.js