Skip to content

Instantly share code, notes, and snippets.

@davidji99
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save davidji99/9336391 to your computer and use it in GitHub Desktop.

Select an option

Save davidji99/9336391 to your computer and use it in GitHub Desktop.
window.myInterval = setInterval(function() {
if ($("some-selector").length > 0) { //looks for a selector
/*
do something here
or add/or in a custom event goal like below:
*/
window['optimizely'] = window['optimizely'] || [];
$("someselector").bind("mousedown", function() {window.optimizely.push(["trackEvent", "eventName"]);
});
clearInterval(window.myInterval); //after it's found, clear the interval
}
}, 50) //in milliseconds;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment