Skip to content

Instantly share code, notes, and snippets.

View robisatthefunction's full-sized avatar

Robert Saunders robisatthefunction

  • Optimizely
View GitHub Profile
{
"plugin_type": "widget",
"name": "Optimizely Product Recommendations",
"edit_page_url": "https://p13n.opti-demo.online/",
"form_schema": [
{
"name": "header",
"options": null,
"label": "Header Text",
"default_value": "You might also love",
import { enums } from '@optimizely/optimizely-sdk';
// import your third-party analytics integration here
///////////////////////////////////////////
// SET UP DECISION NOTIFICATION LISTENER //
///////////////////////////////////////////
const onDecision = ({decisionType, userId, attributes, decisionInfo}) => {
if(decisionInfo['decisionEventDispatched']){
// This assumes the userContext is instantiated
// Ensure Contentsquare is available
async function checkIPAddress() {
// Using a public IP API service to get the visitor's IP
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
const visitorIP = data.ip;
return visitorIP
}
import boto3
# Get AWS credentials from your Optimizely Interface https://docs.developers.optimizely.com/web/docs/customer-profiles#bulk-upload
client = boto3.client(
's3',
aws_access_key_id = '',
aws_secret_access_key = ''
)
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-bucket-intro.html
WITH events_with_experiment_in_array AS (
SELECT visitor_id,
revenue,
experiments
FROM events
WHERE account = '4268742351'
AND event = 'seat_revenue'
AND cardinality(filter(experiments, e -> e.experiment_id = '25565530461')) > 0
), events_with_experiment_column AS (
SELECT visitor_id,
WITH tbl_events AS (
SELECT e.*, t.exp.experiment_id, t.exp.variation_id
FROM events e
CROSS JOIN UNNEST(e.experiments) AS t(exp)
WHERE t.exp.experiment_id = '24298220083'
AND e.entity_id = '24209830080'
AND e.timestamp BETWEEN TIMESTAMP '2023-05-18 18:13:00' AND TIMESTAMP '2023-05-25 14:09:10'
),
dec_tbl AS (
SELECT visitor_id, experiment_id, timestamp
window["optimizely"].push({
"type": "addListener",
"filter": {
"type": "lifecycle",
"name": "initialized"
},
"handler": function(event) {
var utils = window.optimizely.get('utils');
utils.waitUntil(function(){
{
"plugin_type": "widget",
"name": "Sliding Card",
"edit_page_url": "www.optimizely.com",
"form_schema": [
{
"default_value": "For more of what you want, when you want it.",
"field_type": "text",
"name": "heading",
"options": null,
function getCookie(name){
var match = document.cookie.match(name + '=([^;]*)');
return match ? match[1] : undefined;
}
var tealium_cookie = getCookie('utag_main');
function setTealiumIds(tealium_cookie) {
if(!!tealium_cookie){
var tealium_vid = tealium_cookie.split('v_id:')[1].split('$')[0];
{
"account_id": "9258012290",
"visitors":
[
{
"visitor_id": "oeu1724084099999r0.3613393116266512",
"attributes": [],
"snapshots": [
{
"decisions": [],