Utilizing Events from Open edX via Segment.com

One of the nice things about Open edX is that it comes with built-in Segment.com support.

And you immediately say to yourself “so what?”

Well here’s the benefit: if your intention is to use 3rd party tools to make use of the data that Open edX generates, say send some automated emails to users who enrolled in a course, you can use the events arriving through Segment and plug them into (in this case) services that do email automation, like Autopilot or Customer.io. You don’t need any custom code within Open edX, the events are already packaged and sent to Segment.com.

To enable Segment in Open edX, all you have to is set the appropriate EDXAPP variables in your ansible build (details on building Open edX are outside the scope of this blog post….ehh….to say the least.)

Open edX will then start sending relevant events to Segment.com from both code inside the Django app as well as a Javascript tracker embedded in the actual web pages.

Let’s say you are interested in doing something when a user enrolls in a course. When a user enrolls, a ‘track’ event is sent to Segment from the emit_event method in the Open edX Student model. (See it here on line 1201 in edx-platform on github)

When it gets to Segment.com it looks something like this:

 

Ok, so Segment.com is just a data broker, so what now?

You’ve got to attach that event to something that can utilize it or make sense of it. In this case, we could use a service like Autopilot to send an automated email for this event. You can set up Autopilot to watch for events of type edx.course.enrollment.activated  and start your email workflows when you see it. Here’s a simple one I set up (gotta love that visual workflow designer) that just sends out a targeted message after the student enrolls:

 

Screenshot of 'enrolled in course' workflow in Autopilot

 

That workflow is pretty basic. You could probably hack it by just skipping Segment and adding code directly to the Student model in Open edX to sending a direct event to somebody like SendGrid. But that’s ugly, so maybe you could write a Django IDA to plug into Open edX. But that’s time intensive and another thing for you to manage. So, given the tools a proper email automation SaaS should provide (tagging, branching, etc.) you could do quite a bit of cool stuff with minimal effort using this approach. For example, send out a reminder 3 days after enrolling if the user hasn’t yet logged in again. Or direct the user to a questionnaire 3 days after the the ‘unenrolled’ event.

The problem with these nice, fancy, borne-from-the-minds-of-ecommerce-specialists applications is that they ccoooosssst. Every one you look at seems to charge $300/month upwards if you have anything near decent traffic. Now, if you get a big financial return from a 1% uptick in sales because people dig your personalized emails, you don’t care. But if you’re running a site like Open edX in a non-profit context and measure your success in terms of improved learning and more course content viewed, you do care!

Cost aside, it’s a pretty cool set up. Segment.com and Autopilot have free accounts, and I was able to set up a working workflow in a matter of hours. So give it a go, but don’t forget to check out the monthly costs…they’re not cheap!

 

Leave a Reply