Elevate AB Testing with window.dfc

Getting Started

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

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

The un-minified version is Long Form: here

Helper Function

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