Track Time Spent on Thinkific Courses
Monitor how long students spend time on Thinkific lessons in Mixpanel.
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
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.
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.
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.
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.
Above will get us the duration for most of the cases except for one.
The callback function is:
beforeunload.Code will remain the same as
contentWillChange only the handler is different.
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.
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.
Check out the below article for further instructions about the footer code and callback function of the website