- creation of Metrics (which is SiteSpect's name for Campaign/Variation "goals")
- creation of (Standard) Campaigns
- creation of Variations
- creation of Global Variations
All these points are relevant for the requirements of Team Sonic, which are:
| /* Place this code in Project JS. | |
| * This code randomly selects either one experiment marked with an [ME], one experiment from each group denominated with [Group_A] where A is any character the user wishes to use. The code is evaluated before url targeting and audiencing. | |
| * | |
| * The way it works is: | |
| * - Let's say we have 3 groups with 3 experiments in each group, 3 experiments marked with an [ME], and 5 experiments not marked with a [Group_X] or an [ME]. | |
| * [Group_A] Exp 1, [Group_A] Exp 2, [Group_A] Exp 3, [Group_A] holdout | |
| * [Group_B] Exp 4, [Group_B] Exp 5, [Group_B] Exp 6, [Group_B] holdout | |
| * [Group_C] Exp 7, [Group_C] Exp 8, [Group_C] Exp 9, [Group_C] holdout | |
| * [ME] Exp 10, [ME] Exp 11, [ME] Exp 12, [ME] holdout | |
| * |
| // all of this is made possible by the optimizely javascript api, specifically: | |
| // http://developers.optimizely.com/javascript/reference/#the-data-object | |
| function getExperiments() { | |
| var experimentInfo = {}; | |
| var wasRedirected = false; | |
| /* | |
| * create an array of experiments that are active on the page | |
| * you must pass two tests to be placed in an active experiment: | |
| * 1) url targeting: https://help.optimizely.com/hc/en-us/articles/200040835-URL-Targeting-Choose-where-your-experiment-runs |
| // Top-level functions | |
| window.optimizely.get('state'); | |
| window.optimizely.get('data'); | |
| window.optimizely.get('visitor'); // For custom attributes and such | |
| window.optimizely.get('behavior'); // For behavior queries | |
| // Common examples | |
| window.optimizely.get('state').getActiveExperimentIds(); // Returns an array of active experiment IDs on a page. | |
| window.optimizely.get('data').revision; // Returns the revision that the snippet on the page is on. Useful in determining whether you are looking at the most updated changes made within a campaign. | |
| window.optimizely.get('state').getVariationMap(); // Returns an object of experiment IDs and the corresponding variation ID a user has been bucketed into. Equivalent of classic Optimizely Testing's optimizelyBuckets cookie (which is no longer available within Optimizely X Web). |
| (function(){ | |
| // Return if the page hasn't loaded | |
| if (document.readyState !== "complete") { alert("Please wait for the page to load"); return; }; | |
| // Return if Optimizely isn't available | |
| if (typeof window.optimizely !== "object") { alert("Optimizely isn't available"); return; } | |
| // Collect and assign optimizely data | |
| var data = window.optimizely.data; |
| javascript:(function(){var names="";for(var i=window["optimizely"].data.state.activeExperiments.length-1;i>=0;i--){var experimentId=window["optimizely"].data.state.activeExperiments[i];names+='<p style="font-size: 12px;">'+window["optimizely"].data.experiments[experimentId].name+"</span>";}var el=document.createElement("div");el.style.cssText="position: fixed; top: 0; right: 0; width: 15%; background: #000; color: #fff; padding: 5px; text-align: center;";el.innerHTML=names;var body=document.getElementsByTagName("body")[0];body.appendChild(el);window.setTimeout(function(){el.remove();},3000);})(); |
| // Assume either 0 or 1 experiment is running | |
| var findActiveExperiment = function(optimizely) { | |
| if(optimizely && optimizely.activeExperiments.length > 0) { | |
| var expId = optimizely.activeExperiments[0]; | |
| var experiment = optimizely.activeExperiments[expId]; | |
| return { | |
| id: expId, | |
| experiment: optimizely.allExperiments[expId] | |
| }; | |
| } |
| // Easy load Optimizely Experiment Variations on the current page | |
| // https://help.optimizely.com/hc/en-us/articles/200107480-Force-a-specific-variation-to-run-and-other-URL-parameters- | |
| javascript: (function() { | |
| // e.g. 942857,1 | |
| var answer = window.prompt("Enter the optimizely experiment id and variation id separated by a comma", ""); | |
| if (answer) { | |
| var split = answer.split(','); | |
| var path = window.location.pathname; | |
| if (path.indexOf('?') > 0) { | |
| // url has a ? so use a & |
| // Optimizely JavaScript API | |
| // http://developers.optimizely.com/javascript/ | |
| // To opt a visitor out of Optimizely tracking | |
| // http://www.example.com/page.html?optimizely_opt_out=true | |
| // 1. API Function Calls | |
| // http://developers.optimizely.com/javascript/#api-function-calls-2 |