Last active
June 27, 2023 21:17
-
-
Save robisatthefunction/ee8dfaa293a6b6e64d44b630d8be2454 to your computer and use it in GitHub Desktop.
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
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