Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embeded Vimeo Video progress Tracking

On one of my website I am using a vimeo video link to show a video. Now I am having a requirement to track the video progress. like the duration a learner spent on that particular page or the percentage of video viewed by the user. Is it possible to track this in JavaScript

like image 642
nidheesh nair Avatar asked Oct 22 '25 06:10

nidheesh nair


1 Answers

Using player.js you can use the below code

<script src="https://player.vimeo.com/api/player.js">
const player = new Vimeo.Player("video_id"); 

player.on('timeupdate', function(data){
  console.log( data.seconds );
});

Hope it will help you.

I have used it with a WordPress site to track the progress using the code below:

player.on('timeupdate', function(data){
        var running_time = data.seconds;
             $.ajax({
                url : '<?php echo admin_url("admin-ajax.php" ) ?>',
                data : {
                    action: "storeinDB",
                    user_id : "<?php echo $user->ID; ?>",
                    post_id : "<?php echo get_the_ID(); ?>",
                    running_time : running_time },
                dataType : "post",
                type: "post",
                success: function(response){
                    //console.log(response);
                }
            });
    });

thanks


Related resources:

  • Tracking progress in embedded Vimeo videos
like image 105
Anoop Saini Avatar answered Oct 23 '25 21:10

Anoop Saini