Advertising events in API


You can catch ad events via JS API if you enable the Track VAST events option in the API settings

Events come with the vast_ prefix

function PlayerjsEvents(event,id,info){
   if(event=="vast_Impression"){
      console.log(event, info);
   }
   if(event=="vast_Error"){
      console.log(event, info); //there will be an error code in info
   }
}

You can catch the end of an ad block using the vast_finish event and request information about current advertising with vastinfo

player.api("vastinfo");

The player will return an object with information in response.


21.0.1
2025 © PlayerJS

Sign up

Sign up
By signing up, you agree to Terms of Service
Login if you have an account

Restore password

Restore
Forgot email? Contact us