Created
March 22, 2021 18:34
-
-
Save rdundon/94b2c97647f6d02eca5d5646c04c7ed0 to your computer and use it in GitHub Desktop.
Revisions
-
rdundon created this gist
Mar 22, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ // "videoTag" is <video> element pulled from the DOM var videoPercentageRate = this.duration / 100; var videoCompletionRateIntervals = [25,50,75,100]; videoTag.play = function() { var percentageCompleted = (videoTag.currentTime / videoTag.duration) * 100 console.log(percentageCompleted); if (percentageCompleted >= videoCompletionRateIntervals[0]) { console.log(videoCompletionRateIntervals[0], '% of video completed'); // GA Event videoCompletionRateIntervals.splice(0,1); } if (videoCompletionRateIntervals.length == 0) { videoTag.play = null; } }