如何跟踪用户观看了多少YouTube视频? [英] How to track how much of a youtube video the user has watched?

查看:234
本文介绍了如何跟踪用户观看了多少YouTube视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要跟踪用户在我的网站上观看了多少嵌入式youtube视频.我需要它在视频长度的25%,50%,75%和100%处触发标签.它应该与滚动页面轨道类似地工作.

我对该网站的唯一访问权是通过Googletag管理器,因此任何解决方案都必须通过那里.

我已经进行了研究,并且显然可以使用youtube api来做到这一点.我什至尝试了此分步指南:解决方案

请看看

使用jQuery和Google Analytics(分析)跟踪YouTube视频播放活动

https://developers.google.com/youtube/js_api_reference

您需要跟踪当前播放时间,获取总播放时间,然后将其转换为百分比.

使用无镶边播放器并使用youtube js api.请参阅Playback_status方法.我同意安排一个计时器.但是,强烈建议您使用js api上的方法和回调.

您可能必须使用

onStateChange事件 getDuration() getCurrentTime()

,您可能需要在onStateChange包装器内部或更好的内部包装.

function onYouTubePlayerReady(playerId) {
  ytplayer = document.getElementById("myytplayer");
  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {
   alert(ytplayer.getDuration()+ytplayer.getCurrentTime());
}

在播放器状态更改时,您可以在内部触发自己的方法.

这不是一个可行的示例,但我希望您能得到我的答案.模态/弹出框与获取所需数据无关.您只需要使用chromeless播放器和YT js api即可与jQuery插件协同工作.有一些jQuery插件是用于多种视频共享技术的API包装器.

鲍尔和Google是您的朋友!

http://bower.io/search/?q=youtube

I need to track how much of an embedded youtube video the user has watched on my site. I need it to fire a tag at 25%, 50%, 75% and 100% of the length of the video. It should work similarly as a scrolling page track.

The only access I have to the site is through Googletag manager, so any solution would have to be through there.

I´ve researched and aparently there are ways to do this using youtube api. I even tried this step-by-step guide: http://www.cardinalpath.com/youtube-video-tracking-with-gtm-and-ua-a-step-by-step-guide/ But it didn´t work.

I guess the problem is that the site uses fancybox the play the video. Here is a pick of the website´s code:

I have no idea where to start.

解决方案

Please take a look at

Track YouTube Video Playback with jQuery and Google Analytics Events

https://developers.google.com/youtube/js_api_reference

You need to track the current playback time, get the total playing time and then convert it to percentages.

Use the chromeless player and use the youtube js api. See the Playback_status method. I agree with putting a timer. However, there are methods and callbacks available at the js api that I highly recommended for you to use.

You will probably have to use

onStateChange event getDuration() getCurrentTime()

and you probably need those inside the onStateChange wrapper or something better.

function onYouTubePlayerReady(playerId) {
  ytplayer = document.getElementById("myytplayer");
  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {
   alert(ytplayer.getDuration()+ytplayer.getCurrentTime());
}

At the player state change, you may fire your own methods inside.

It's not a working example, but I hope that you get my answer. The modal / popup boxes is not related in getting the data needed. You just need to use the chromeless player and the YT js api working in harmony with your jQuery plugins. There are some jQuery plugins that is an API wrapper for multiple video sharing technologies.

Bower and Google is your friend!

http://bower.io/search/?q=youtube

这篇关于如何跟踪用户观看了多少YouTube视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆