- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
I have found only one comperehensive post on YouTube Video Events tracking here:
(Successfully implemented)
The only question that was not fully answered was about YouTube Video Milestones tracking.
Is it possible to get any assistance with the YouTube Video Milestones tracking in Tealium iQ? A couple of code examples will suffice.
Solved! Go to Solution.
Hi @alexander_shabe. We are working on getting an answer for you. Thank you for your patience.
So after some experimenting here is a code snippet that I got working that would fire a milestone event once, per each milestone.
var playerCheckInterval; var mileStones = [1,2,25,50, 75] function onPlayerStateChange(event) { if (event.data == YT.PlayerState.PLAYING) { playerCheckInterval = setInterval(mileStoneCheck, 100); } else if (event.data == YT.PlayerState.PAUSED) { clearInterval(playerCheckInterval); //Send PAUSED Event } else if (event.data == YT.PlayerState.ENDED ) { clearInterval(playerCheckInterval); //Send ENDED Event } } function mileStoneCheck() { var duration = player.getDuration(); var percComplete = (player.getCurrentTime() / player.getDuration()) * 100; var ms_len = mileStones.length; if (ms_len > 0) { var next_ms = mileStones[0]; if (next_ms <= percComplete) { mileStones.shift(); console.log("mileStoneCheck", next_ms, percComplete, player.getCurrentTime()); } } }
Hope this helps.
Adrian
Copyright All Rights Reserved © 2008-2023