<script src="//www.domain.com/videojs/video.min.js"></script><script src="//www.domain.com/videojs/nuevo.min.js"></script><script src="//www.domain.com/videojs/plugins/videojs.events.js"></script>
var player = videojs("myPlayer");player.nuevo({title:"video title", video_id:"video id"});player.events({analytics:true});
player.on('track', (e, data) => {if (data.event === 'firstPlay') {let session_id = data.sessionId;let video_id = data.videoId;let video_title = data.videoTitle;let category = data.category;let duration = data.duration;let start_time = data.initialTime;// do something with data...}});
player.events({ abstractApiKey: "Your API Key" });orplayer.events({ ipdataApiKey: "Your API Key" });
player.events({ anonymizeIP: true });
userevent's object.
player.on('track', (e, data) => {if (data.event === 'user') {let user_ip = data.userInfo.ip_address;let city = data.userInfo.city;let region = data.userInfo.region;let country = data.userInfo.country;let country_code = data.userInfo.country_code;let country_code = data.userInfo.country_code;let browser = data.userInfo.browser;let device = data.userInfo.device;}});
getSummaryallows to extract summary data in javascript at any time position, not only when video ended. This may be useful for apps with dynamic routing, to catch video summary data before dynamic navigation.
let summarydata = player.getSummary();
let session_id = summarydata.session_Id;
let video_id = summarydata.video_Id;
let video_title = summarydata.videoTitle;
let category = summarydata.category;
let watched_time = summarydata.watchedTime;
let pause_count = summarydata.pauseCount;
let resume_count = summarydata.resumeCount;
let seek_count = summarydata.seekCount;
let buffer_duration = summarydata.bufferDuration;
player.events({ trackingUrl: "https://script_url" });
{event: "firstPlay",value: 0,sessionId: "unique timestamp",category: "video",videoId: "Id of the video",videoTitle: "Titlte of the video"}
Event name | Event value(sec) |
firstPlay | start time (s) |
progress | 10%, 25%, 50%, 75% or 90% |
replay | null |
completed | video duration (sec) |
fullscreen | 1 or 0 |
watchedTime | time (sec) |
user | ip_address, city, region, country, country_code, browser, device |
$data = file_get_contents("php://input");$data = json_decode($data);
$event_name = $data->event;$event_value = $data->value;$session_id = $data->sessionId;$category = $data->category;$video_id = $data->videoId;$video_title = $data->videoTitle;
$data = file_get_contents("php://input");$data = json_decode($data);
$event_name = $data->event;if($event_name=='user') {$user = json_decode($data->value);$ip = $user->ip_address;$city = $user->city;$region = $user->region;$country = $user->country;$country_ip = $user->country_ip;$browser = $user->browser;$device = $user->device;}