Skip to content

Instantly share code, notes, and snippets.

@saeef
saeef / README.md
Created March 5, 2020 23:59 — forked from dlueth/README.md
SiteSpect Implementation

SiteSpect

What did we test

  • 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:

// JavaScript Document
(function () {
document.addEventListener("DOMContentLoaded", function (event) {
var cardsCounter;
var stackedOptions = 'Top'; //Change stacked cards view from 'Bottom', 'Top' or 'None'.
var rotate = true; //Activate the elements' rotation for each move on stacked cards.
var items = 3; //Number of visible elements when the stacked options are bottom or top.
var elementsMargin = 10; //Define the distance of each element when the stacked options are bottom or top.
var useOverlays = true; //Enable or disable the overlays for swipe elements.
var maxElements; //Total of stacked cards on DOM.
/* 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
*
@saeef
saeef / optimizely_info.js
Created May 2, 2018 21:57 — forked from msure/optimizely_info.js
Get Information About Active Optimizely Experiments
// 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
@saeef
saeef / optimizely-x-js-api.js
Created May 2, 2018 21:37 — forked from jamesspittal/optimizely-x-js-api.js
JS API calls for Optimizely X
// 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).
@saeef
saeef / gist:6aa7f102f0322006fef9dc6552703cce
Created May 2, 2018 21:32 — forked from dannycroft/gist:3237084
Show Optimizely Settings
(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;
@saeef
saeef / gist:4bb47ea27d8b9e6098eec992d0798d48
Created May 2, 2018 21:31
display list of optimizely tests
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 &
@saeef
saeef / diningPagePopup.js
Created February 26, 2018 20:42
My Editey Script
var $ = window.jQuery;
var isButlinDining = {
init: function() {
this.isMainCSS(true);
this.isPageStart();
this.isPopupBuild();
this.isBindEvent();
},