Created
December 10, 2016 00:10
-
-
Save bwll/433431511a9fb220997c731467c5d224 to your computer and use it in GitHub Desktop.
Callback function for activating a Page in Optimizely X when Demandbase object has loaded
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
function callbackFn(activate, options) { | |
// Interval in ms for polling Demandbase visitor data | |
var POLL_INTERVAL = 50; | |
// Max number of poll attempts | |
var MAX_POLL_COUNT = 5; | |
var pollCount = 0; | |
function poll() { | |
pollCount++; | |
if (window.optimizely && | |
window.optimizely.get('visitor') && | |
optimizely.get('visitor')['vendor.demandbase'] && | |
!options.isActive) { | |
activate(); | |
} else if (pollCount < MAX_POLL_COUNT) { | |
setTimeout(poll, POLL_INTERVAL); | |
} | |
} | |
poll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment