Track Time Spent on Thinkific Courses

Monitor how long students spend time on Thinkific lessons in Mixpanel.

Muffaddal Qutbuddin
4 min readFeb 4, 2021
source pixabay, by anncapictures

Thinkific is a platform to make it easy to create, market & sell online courses. Everything you need to run your education business under one roof.

However, one thing it lacks is the ability to track the session duration for each student. You can’t monitor how much time students spent on courses.

We can leverage Mixpanel analytics for this purpose. It allows analyzing user's (students in our case) behavior across your sites with a real-time cohort.
The best part is Thinkific has direct integration to Mixpanel.

Here is how it will look in the Mixpanel

Lesson duration report of Thinkific in Mixpanel, by Muffaddal

But having Mixpanel integration with Thinkific doesn’t mean we will get the session duration tracking reports in Mixpanel. We have to tailor Mixpanel tracking to attain our objective. And that’s this article will help you explain.

Note The method requires a Javascript background. And I won’t go into detail about the code-related stuff here. So better ask a technical person in your team to do this for you.

Feel free to reach out if you require my help with the implementation

There are two concepts that we need to grasp to make this work for us.

First is how Mixpanel tracks time with the event.
The second is how to employ that with Thinkific’s callback functions

let discuss them one by one in detail.

Duration Tracking in Mixpanel

To calculate duration in Mixpanel we have to tell it when to start the timer and when to stop it. Here is how it is done.

To start timer we call mixpanel.time_event and pass along the name of the event till which to calculate the time elapsed.

Suppose we want to calculate the time between login and log out of users. We will call mixpanel.time_event when the user login and pass it to log out event name. Here is the example code for it.

duration tracking in Mixpanel

We have to follow the same idea for Thinkific.

Thinkific Callfack Functions

Thinkific provides callback functions that get triggered when a user performs a certain action. Below are the hooks currently available.

callback functions available in Thinkific

Now how to employ these to get us the duration tracking in Mixpanel? We need to do two things. First, when a user views any course we trigger mixpanel.time_event call. Second, send the name of when the user exit the page.

To start the timer hooks:contentDidChange is what we need. It triggers when a new lesson is viewed.

To stop the time hooks:contentWillChange can be used. It triggers when a user is about to leave a lesson.

duration tracking flow in Thinkific, by muffaddal

Above will get us the duration for most of the cases except for one.

There is one edge chase where users instead of marking the lesson complete they close the browser tab. In this scenario, we will have to make use of javascript’s callback function that triggers before the browser window is about to close.

The callback function is: beforeunload.Code will remain the same as contentWillChange only the handler is different.

And done!

no net yet, we still have to add the code to the website.

Add Custom Code in Thinkific Website

We know what to do with the code, but the question is where to add it? Thinkific provides a way to add any custom code inside the footer section of the website. To do so, go to settings>site footer code>code & analytics tab.

add code to the footer section of Thinkific website, source Thinkific

Paste the code in the code layout depicted above, hit save, and changes will start to reflect immediately on the website. You can go to Mixpanel’s live view to see events in realtime.

Reach me out if you need help tracking time spent by users on your courses.

References

Check out the below article for further instructions about the footer code and callback function of the website

--

--

No responses yet