Skip to content

Instantly share code, notes, and snippets.

View robisatthefunction's full-sized avatar

Robert Saunders robisatthefunction

  • Optimizely
View GitHub Profile
function () {
var shipping_value = document.querySelectorAll("span.right.ng-binding")[document.querySelectorAll("span.right.ng-binding").length - 2];
var cart_total = document.querySelectorAll("span.right.ng-binding")[document.querySelectorAll("span.right.ng-binding").length - 1];
var bucket = false;
for (var i=0; i<window.dataLayer.length; i++) {
if (window.dataLayer[i].subProgramName === "Fall Individuals") {
/**
* Sample JavaScript Condition
* This function is called after the page is triggered. It should return true
* when the page is ready to activate.
*/
function () {
var bucket = false;
for (var i=0; i<window.dataLayer.length; i++) {
// npm install --save @optimizely/optimizely-sdk request request-promise prompt-input
const userId = process.argv[2] || 'anonymous123';
const url = 'https://cdn.optimizely.com/datafiles/Pex4GNxQnzDErs3TJZ7cc3.json';
const rp = require('request-promise');
const Input = require('prompt-input');
const options = {uri: url, json: true};
const optimizelySDK = require('@optimizely/optimizely-sdk');
const dimColor = '%s';
var url = window.location.href;
if (url.indexOf('thank-you') > -1) {
var plan = url.split('/')[5];
if (plan == "M") {
window["optimizely"] = window["optimizely"] || [];
window["optimizely"].push({
type: "user",
attributes: {
"plan": "monthly"
}
(function(_pushState) {
var pushState = history.pushState;
history.pushState = function(state) {
if (typeof history.onpushstate == "function") {
history.onpushstate({
state: state
});
}
{
"account_id": "your_account_id",
"visitors":
[
{
"visitor_id": e.optimizely_dna__Visitor_Id__c,
"attributes": [{
"entity_id": "19213743593",
"key": "example_key",
"type": "custom",
// Place this clode below the Optimizely snippet
var first_session = window.optimizely.get('visitor').first_session
if (first_session == true) {
first_session = "true";
} else if (first_session == false) {
first_session = "false";
}
window.optimizely = window.optimizely || [];
var segments = document.querySelector('#root > div.wrap.position--relative > div > div > div > div > div > div.flex--1.js-popover-scroll-area.results-col.overflow-y--auto > div.toolbar > div > div.toolbar__left > div.lego-dropdown-group.is-active > ul > li.hard--sides.lego-dropdown__item > ul > div:nth-child(3) > div').children
function segmentSelect(search) {
for (var i=0; i<segments.length; i++) {
if(segments[i].innerText.indexOf(search) > -1) {
segments[i].firstChild.firstChild.firstChild.click()
}
}
}
/* This snippet runs everytime a "campaign decision" is made. */
var decisionObject = window.optimizely.get('state').getDecisionObject({
campaignId: campaignId,
shouldCleanString: true
});
//Check to see if a decision has been made. This will be null if the user is part of the holdback group
if (decisionObject) {
var experimentId = decisionObject.experiment.split(' ')[1].replace(/[()]/g, '');
var variationMap = window.optimizely.get('state').getVariationMap();
typeof(variationMap[23243453455]) === "undefined" && typeof(variationMap[23423434752]) === "undefined";