Friday, August 30, 2013

Django unchained - python in the cloud

I was experimenting with the django web framework. First I found this helpful tutorial: http://effectivedjango.com/tutorial/getting-started.html. I really liked that it's starting from the basics which makes it usable for python beginners too.

After reading the tutorial I wanted to create a django project in the cloud. My first idea was to use Google App Engine because it has python support and it's free for small projects. I found this tutorial http://www.allbuttonspressed.com/projects/djangoappengine about running django projects on Google App Engine but I realized that I have to extend django with support for non relational databases. I found this step a bit complicated. There was an other tutorial to run django with Google Cloud SQL but it turned out to have no free version.

So keep the story short after spending several hours to find out how to run my django project on Google App Engine I find myself in searching for other free django hosting solutions. And I come across pythonanywhere.com and it was a really nice surprise for me. It doesn't have so many features like Google App Engine but it's optimized for python. I finished the registration in 5 minutes and it was really easy to find a description how to run django project here (https://www.pythonanywhere.com/wiki/DjangoTutorial). It took me just 30 minutes to configure everything end write a hello world application from the scratch in their in browser console (yes, they have an in browser bash console) and open it in my browser for the first time.

So just to summarize my positive impressions about pythonanywhere.com:
  • free plan with mysql support
  • web based bash console
  • really easy to set up
  • good tutorial (first I missed how to refresh the server, but it was just at the end of the tutorial)
  • they have dropbox sync which makes synchronization very straightforward
  • easy way to check access and error logs
I also heard good things about heroku. They also have a good getting started guide. Maybe worth to try it as well:  https://devcenter.heroku.com/articles/django

Additionally here is a really short introduction video:

Tuesday, August 13, 2013

Simple A/B test in Google Analytics

Google has it's A/B testing solution called "Content Experiments". Originally it was designed to test different page alternatives. In this case you had to build two different version of the whole page or website (link). This can be quite complicated. Google announced his new "Content Experiment API" which is more flexible but for me it's also a bit complicated for very simple tests. On the other side there is a really simple way to implement A/B tests on a website. Let's see how!

For the A/B testing we will use a couple of lines of JavaScript code. You can do any kind of split on your users but for now we will use a simple random split. The result of the split is stored in a long living cookie.


After having the A/B test cookie, the only thing you have to do, is changing your site behavior based on the cookie and passing the group value to the Google Analytics.
Very simple content experiment. ]]>
To have the same groups in the Google Analytics you only have to add this two lines to your original GA tracking code (more description in GA help): ]]>
To check the result in GA you only have to define custom filters in GA. Here are some screen shots how to do this: