Course Player Event Hooks

    Plan Availability
    Legacy Plans
    Platform

Event Hooks

The Course Player exposes javascript events that you can listen for with custom javascript placed in the Site Footer Code. These Event Hooks allow you to write your own custom javascript and use it to interact with our Course Player. You can use this to send data on student course navigation, and course and lesson completion, to your analtyics tools custom applications.

Available Hooks

The following hooks are currently available to you:

Event Description
hooks:contentDidChange Fired after a student has navigated to a new lesson.
hooks:contentWasCompleted Fired when the student clicks the Next button and completes the lesson.
hooks:contentWasMarkedIncomplete Fired when the student clicks the Mark Incomplete button on a previously completed lesson.
hooks:contentWillChange Fired just before a student navigates to a new lesson. Your function will receive a second parameter call abortTransactionCallback. If you choose to, you can call this function with a boolean value. If you call it with true, the transition to the new lesson will be canceled. If you call it with false, the transition will continue. If you do not call it, the transition will continue.
hooks:enrollmentWasCompleted Fired when the student completes the entire course and their enrollment percentage complete reaches 100%.

Event Data

All 5 events pass the same data:

var data = {        
  lesson: {} //object containing lesson attributes,
  chapter:  {} //object containing chapter attributes,
  course:  {} //object containing course attributes,
  enrollment:  {} //object containing enrollment attributes,
  user: {} //object containing student attributes
}

Example Usage

Below is an example of a script which would fire when a student clicks the "Next" button and completes the lesson:

<script>
  $(function() {
    if(typeof(CoursePlayerV2) !== 'undefined') {
      CoursePlayerV2.on('hooks:contentWasCompleted', function(data) {
        data["user"] = Thinkific.current_user;
        ThinkificAnalytics.track("Custom Content Completed", data);
      });
    }
  });
</script>
Was this article helpful?
3 out of 6 found this helpful