How to get “Seconds Played” and “Percentage Played” events from JW Player 6 in GA

时间秒杀一切 提交于 2019-12-07 18:24:17

问题


I see the new JW Player 6 Enterprise has lost the capability to report Seconds Played and Percentage Played as Google Analytics Events.

Has anyone developed a method to produce something like this? I imagine the JW Player API and some JavaScript could support these events.

[We made great use of the Seconds Played and Percentage Played capabilities in JW Player 5, and I'm sad to see it go. If anyone from JWPlayer is listening: it would be great to have those events back!]


回答1:


I think you could recreate the seconds played tracking on your own with the onTime callback. Try this:

var currentDuration = -1;
var currentPosition = -1;
var jw = jwplayer();
jw.onTime(function() {
    var position = this.getPosition();
    var duration = this.getDuration();
    if ((duration === currentDuration && position === currentPostion) || duration === -1 ) {
      return;
    }
    currentPosition = position;
    currentDuration = duration;
    var file = this.getPlaylistItem().file
    return _gaq.push(['_trackEvent', 'JW Player Seconds Played', file, window.location.href);
});


来源:https://stackoverflow.com/questions/26170231/how-to-get-seconds-played-and-percentage-played-events-from-jw-player-6-in-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!