Skip to content

Instantly share code, notes, and snippets.

@isquick82
Last active November 18, 2019 22:20
Show Gist options
  • Save isquick82/50e440ddaff85a77e181f6ae87a16d11 to your computer and use it in GitHub Desktop.
Save isquick82/50e440ddaff85a77e181f6ae87a16d11 to your computer and use it in GitHub Desktop.
// 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
optimizelyClientInstance.track('purchase', userId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment