This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// optimizely.js | |
import optimizelySdk from '@optimizely/optimizely-sdk' | |
const optimizelyClientInstance = optimizelySdk.createInstance({ | |
datafile: window.optimizelyDatafile, | |
}) | |
export default optimizelyClientInstance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save @optimizely/optimizely-sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdn.optimizely.com/datafiles/<Your_SDK_KEY>.json/tag.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A/B Test for Adding a Discount Option to Product | |
if (enabled) { | |
// The variable amount can be remotely configured from Optimizely UI | |
const discountAmount = optimizelyClientInstance.getFeatureVariable('discount', 'amount', userId); | |
console.log(`${userId} got a discount of $${discountAmount}`); | |
} else { | |
console.log(`${userId} did not get the discount feature`); | |
} | |
//after we’ve confirmed purchase completed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import optimizelyClientInstance from './optimizely' | |
const enabled = optimizelyClientInstance.isFeatureEnabled('new_feature', 'user123'); | |
if (enabled) { | |
// Show your feature | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PATCH https://api.optimizely.com/v2/features/<feature_id> | |
Sample request payload: | |
{ | |
"variables":[ | |
{ | |
"default_value":"30", | |
"id":13322300314 | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST https://api.optimizely.com/v2/features | |
PATCH https://api.optimizely.com/v2/features/<feature_id> | |
Sample request payload: | |
{ | |
"environments":{ | |
"staging":{ | |
"rollout_rules":[ | |
{ | |
"enabled":true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST https://api.optimizely.com/v2/experiments | |
PATCH https://api.optimizely.com/v2/experiments/<experiment_id> | |
Sample request payload: | |
{ | |
"environments":{ | |
"staging":{ | |
"status":"running" | |
}, | |
"production":{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl \ | |
-A "test-user-agent" | |
-H "Content-Type: application/json" \ | |
-X POST -d '{_data_object_}' https://logx.optimizely.com/v1/events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -H "Authorization: Bearer abcdefg123456" \ | |
"https://api.optimizely.com/v2/experiments" |
NewerOlder