am 8f207ca0
: am 2c3ae43f
: am 29e06142
: am d24088c0
: add analytics event to track from which page a video was started
* commit '8f207ca0460c7df2f5ce3b5005312e945c4e48e2': add analytics event to track from which page a video was started
This commit is contained in:
commit
5b566fb929
1 changed files with 9 additions and 3 deletions
|
@ -617,6 +617,9 @@ function startYouTubePlayer(videoId) {
|
|||
|
||||
function onPlayerReady(event) {
|
||||
event.target.playVideo();
|
||||
// track the start playing event so we know from which page the video was selected
|
||||
ga('send', 'event', 'Videos', 'Start: ' +
|
||||
youTubePlayer.getVideoUrl().split('?v=')[1], 'on: ' + document.location.href);
|
||||
}
|
||||
|
||||
function closeVideo() {
|
||||
|
@ -633,15 +636,18 @@ function closeVideo() {
|
|||
function onPlayerStateChange(event) {
|
||||
// Video starts, send the video ID
|
||||
if (event.data == YT.PlayerState.PLAYING) {
|
||||
ga('send', 'event', 'Videos', 'Play', youTubePlayer.getVideoUrl().split('?v=')[1]);
|
||||
ga('send', 'event', 'Videos', 'Play',
|
||||
youTubePlayer.getVideoUrl().split('?v=')[1]);
|
||||
}
|
||||
// Video paused, send video ID and video elapsed time
|
||||
if (event.data == YT.PlayerState.PAUSED) {
|
||||
ga('send', 'event', 'Videos', 'Paused', youTubePlayer.getVideoUrl().split('?v=')[1], youTubePlayer.getCurrentTime());
|
||||
ga('send', 'event', 'Videos', 'Paused',
|
||||
youTubePlayer.getVideoUrl().split('?v=')[1], youTubePlayer.getCurrentTime());
|
||||
}
|
||||
// Video finished, send video ID and video elapsed time
|
||||
if (event.data == YT.PlayerState.ENDED) {
|
||||
ga('send', 'event', 'Videos', 'Finished', youTubePlayer.getVideoUrl().split('?v=')[1], youTubePlayer.getCurrentTime());
|
||||
ga('send', 'event', 'Videos', 'Finished',
|
||||
youTubePlayer.getVideoUrl().split('?v=')[1], youTubePlayer.getCurrentTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue