如何传递来自JW Player for Google Analytics的两个元素的数据?

时间:2015-05-19 10:01:08

标签: video google-analytics jwplayer

JW Player向Google Analytics传输数据不正确 一页上有两个JW Player视频 有以下情况:

<html>
…
<div id=”myvideo1” class="video" data-video-height="140" data-video-width="350" data-video-titel="my test titel 1” data-video-file=”path_to_the_file” data-video-image=”path_to_the_image”></div>
…
<div id=”myvideo2” class="video" data-video-height="290" data-video-width="500" data-video-titel="my test titel 2” data-video-file=”path_to_the_file” data-video-image=”path_to_the_image”></div>
…
<!-- in footer of the page -->
<script type="text/javascript">
$(window).load( function(e)  
{
    var id, height = 0, width = 0, tite, file, image, sources;
    $('.video').each( function(  )
    {
            id     = $(this).attr('id');     
            titel  = $(this).attr('data-video-titel');
            height = $(this).attr('data-video-height');
            width  = $(this).attr('data-video-width');
            image  = $(this).attr('data-video-image');
            file   = $(this).attr('data-video-file');

            sources = [ {'file': file } ];

       jwplayer( id ).setup({
            'height': height,
            'width': width,
            'image': image,
            'sources': sources,
            'events': {
                  onPlay: function (event) {
                        console.log("onPlay::titel: "+titel+", "+jwplayer( id ).getPosition().toFixed(0));                         
                        ga('send', 'event', 'Video Play', titel, event.newstate+": "+jwplayer( id ).getPosition() );
                  },
                  onPause: function (event) {
                         console.log("onPause::titel: "+titel+", "+jwplayer( id ).getPosition().toFixed(0));                         
                         ga('send', 'event', 'Video Pause', titel, event.newstate+": "+jwplayer( id ).getPosition().toFixed(0) +" ( "+id+")" );
                  }
             }
        });
    });
   });

    

此处我只展示了两个针对Google Analytic,播放和暂停的案例 当您点击第二个视频时,使用ID&#34; myvideo2&#34;,数据传输正确,我点击第一个视频&#34; myvideo1&#34;将取出第二个视频数据!
这个源代码必须准确什么?
要正确地将数据传输到谷歌吗?

问候

0 个答案:

没有答案