Created
July 28, 2017 18:32
-
-
Save 33sticks/921a56ebfa04a5508fedfc7ef979fa05 to your computer and use it in GitHub Desktop.
Adobe Analytics YouTube Player Video Measurement Helper Function
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
/*YouTube Player updates required by Adobe Video Tracking module */ | |
var n=0; | |
jQuery('iframe').each(function() { | |
var src = jQuery(this).attr('src'); | |
if(src){ | |
if (src.indexOf('youtube.com') > -1) { | |
if (src.indexOf('?') > -1) { | |
if (src.indexOf('enablejsapi') == -1) { | |
src = src + '&enablejsapi=1'; | |
} | |
} else { | |
src = src + '?enablejsapi=1'; | |
} | |
jQuery(this).attr('src',src); | |
jQuery(this).attr('id','player' +n); | |
n++ | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment