Last active
December 22, 2015 23:26
-
-
Save charliefmoran/0340988b4fc8832c5900 to your computer and use it in GitHub Desktop.
Optimizely event for 75% completion of video in PDK player
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
$(window).load(function() { | |
var isAd = false; | |
$pdk.controller.addEventListener("OnMediaStart", function(event) { | |
if(event.data.baseClip.isAd === true) { | |
isAd=true; | |
} else { | |
isAd = false; | |
window['optimizely'] = window['optimizely'] || []; | |
window.optimizely.push(["trackEvent", "video_start"]); | |
} | |
}, ["*"]); | |
var passed75percent = false; | |
$pdk.controller.addEventListener("OnMediaPlaying", function(event) { | |
if(!isAd && !passed75percent) { | |
if(event.data.percentCompleteAggregate >= 75) { | |
passed75percent=true; | |
window['optimizely'] = window['optimizely'] || []; | |
window.optimizely.push(["trackEvent", "percent_complete_75"]); | |
} | |
} | |
}, ["*"]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment