Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robisatthefunction/ee8dfaa293a6b6e64d44b630d8be2454 to your computer and use it in GitHub Desktop.
Save robisatthefunction/ee8dfaa293a6b6e64d44b630d8be2454 to your computer and use it in GitHub Desktop.
const onDecision = ({ type, userId, attributes, decisionInfo }) => {
// Check if a decision event was dispatched
if (decisionInfo['decisionEventDispatched']) {
// Get experiment bucketing info
const experimentKey = decisionInfo['ruleKey']
const variationKey = decisionInfo['variationKey']
// Optionally send a track event to Optimizely to record integration success. Make sure to have an Optimizely client or withOptimizely client instantiated
optimizely.track('segment_success');
// Send data to analytics provider here
analytics.track('Experiment Viewed', {
'experiment_name': experimentKey,
'variation_name': variationKey
})
}
const notificationId = optimizelyClient.notificationCenter.addNotificationListener(enums.NOTIFICATION_TYPES.DECISION, onDecision);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment