Video wrapper with xAPI tracking
Last updated
Last updated
We need to add this script in the page with the video we want to track using xAPI statements. This will create the window.ADL object we will use to send xAPI statements to LRS.
… track individual/global behaviour inside video (see youtube)!
Before sending any request, first we need to provide LRS configuration
Once we have the LRS configuration ready we can start sending requests to LRS using this function:
The statement structure we are using has 3 parts:
Actor: is the user watching the video
Verb: is the action the user did
Object: identifies the video
This function receives one parameter, the action or verb that we send to LRS. You can create your own verbs but its better to use standard ones, which are already defined in window.ADL.verbs
. They have the following structure, for example for the verb window.ADL.verbs.initialized
:
Next step, we have to select which verbs we will use to track the video, in our case we decided to use:
initialized
when video starts
suspended
when video pauses
resumed
when video plays again
completed
when video ends
So now we know which verbs we want to use and we have all the configuration done, we just have to set listenners for each video event and call the function mentioned above. For example:
on video starts → sendXAPIStatement(window.ADL.verbs.initialized)
on video pause → sendXAPIStatement(window.ADL.verbs.suspended)
on video play → sendXAPIStatement(window.ADL.verbs.resumed)
on video end → sendXAPIStatement(window.ADL.verbs.completed)
You can link any event with any verb you want and this function will send statements to the LRS each time those events are triggered.