Using Mixpanel API In Google App Engine Applications (Python)

We started using MixPanel to get realtime statistics on user engagement in our application. We’ve been using MixPanel before for funnel tracking, but you can’t really appreciate their service until you start using their event tracking. It is truly realtime (as advertised) – the second the user performs an action on your application, you see it on your dashboard.

Besides the realtime reporting what I really like about MixPanel is the fact that they allow easily reporting from your backend and not only from frontend/Javascript (as opposed to Google Analytics).

Within their documentation they have code samples in many languages, including Python. But their Python sample requires ability to start new processes on the server you’re running – something not possible on App Engine. Therefore I changed it to use URLFetch in RPC mode (so that calls to Mixpanel won’t block the call):

It could be re-factored more, like allowing setting the project token outside the function call, but that I will leave for you to do :) (and if you do, please share with us)

Arik

  • MattoTodd

    Thank you much. I had moved a Python app to google apps and couldn't figure out why my events were not making it into mixpanel.

  • http://gregorynicholas.com/ Gregory Nicholas

    i think you should revisit this post and implement the api request using a POST request.

    very quickly, you can max out on the GAE limit of 2048 chars for a URL on any outgoing request.

  • http://www.twitter.com/#!/arikfr Arik Fraimovich

    Good point. You’re welcome to fork the Gist and I will update the post with your forked version :-)

  • http://gregorynicholas.com/ Gregory Nicholas

    hi guys,

    i don’t think it’s a good idea to have “link to user’s website” be the first and most prominent link.. i can’t tell you how frustrating it is to keep clicking on that and getting lost thinking i’m going to the website where the user’s blog is located

    +++++++++++++