A/B split testing with PHP

What is split testing?

A/B split testing is the art of setting up multiple random variants/tests in a controlled experiment. Example tests are different call to actions, different types/locations of buttons, different images, etc.
Your goal? Finding the best converting test, learn from this, and implement this further in your website, thus getting more & more conversions out of existing visitors. Learn why people click and don’t click.

ab-split-testing

Why should you use split testing?

When using split testing, you’ll learn how your visitors think, what works best on your site, and how you can get the most out of all visitors. Optimising websites takes time, but this time may be cheaper then putting another 1000$ in advertising. First optimise, then do some more advertising.

How can you split test in PHP?

There are several PHP libraries which you can use for split testing, and I tested most of them. Here’s my favourites:

Must we use PHP libraries?

Nope.. There are several other ways to integrate split testing in your projects. Here’s some more:

What should we test? Example tests:

And here’s some more articles to help you get started..

 

Any feedback or tips & tricks regarding split testing are more than welcome in the comment section. Good luck!

Laravel 4 released

Great news! My favorite PHP framework Laravel finally released version 4 after 5 public beta’s and months of waiting. Why am I so happy? Well.. it makes my job as a developer a lot simpler compared to my Zend Framework days.

Here’s why you must try Laravel

  • – Smart framework: write less code (faster + easier)
  • – Works with composer, the PHP plugin tool
  • – Filters, events, rest, built-in auth, … it has it all out of the box
  • – Elequent ORM: the smartest and easiest PHP ORM today!
  • – Unit testing for all components

So what’s new in Laravel 4?

  • – L4 now runs on PHP >= 5.3.7
  • – PSR-0 code standards are used
  • – Composer (packagist.org) instead of Laravel bundles
  • – Lot’s of small but convenient little tweaks and options
  • – Mail is now built in
  • – L4 is built with Unit Testing in mind
  • – Great community!
  • – The command line tool (artisan) is now more powerful

 

Here’s what changed in L4:
https://github.com/laravel/framework

Laravel 4 introduction

Download Laravel @ http://laravel.com/, and make sure to follow them on Twitter: https://twitter.com/laravelphp

Facebook: the numbers (infographic)

fb_infographic

Google Universal Analytics: the next big thing?

Today I came across a video about Universal Analytics, Google’s self-proclaimed next big thing.

But is it really? In short? Yes! Here’s why.

What is the difference between Google Analytics and Google Universal Analytics?

Universal Analytics tracks much more than just visits to a website likes Google Analytics does. Where Google Analytics (based on Urchin) tracks visits, Universal Analytics tracks visitors. This allows us to do cross-device tracking which mean even more detailed statistics!

google-universal-analytics

Offline conversions

With the Measurement Protocol you’re now able to ‘plug in’ extra user data, provided by offline/external appliances such as an RFID chip, apps, sensors, etc. Have a look at the YouTube video in my introduction. As a geek, I absolutely love this. The more data the merrier.

Customisable session timeouts

You can now alter this ourselves. Previously this limit was a hard fixed 30 minutes.

Analytics.js

Ga.js becomes analytics.js. The include code also changes.

universal analytics code

Custom dimensions/metrics

Custom dimensions/metrics allows you to create specific metrics in combination with your CRM’s database. See this as custom variables 2.0.

External cost structure

External input, external output. We’re now able to import external costs structures so we can calculate our conversions and ROI even more accurate. Back in the old days.. we could only import Google Adwords costs.

And much, much more..

Here’s some more useful and interesting links I found about Google Universal Analytics:

Did I forgot to mention something very important about Universal Analytics? Please leave a note in the comments 🙂

 

Popular websites 10 years ago

Here’s some screenshots of popular websites (Linkedin, Facebook, Google, Twitter, eBay, YouTube, Wikipedia, Amazon, Hotmail, Blogger, Apple), but 10 years ago.. Pretty neat how things evolved right? Who can still remember this?

websites

Deploying PHP projects with Jenkins on OS X

jenkins

Continuous deployment, automated unit testing, code analysis & reports, git repo’s, Laravel 4 using Composer. This must be a dream project right? Well, yes, if you have it working correctly. It took me a while to get everything working together but now it works like a charm. I chose to deploy via my macbook, but some people might find it handier to install this setup on a public webserver so they can bind their commits to automated deployments, use it as a team, ….
Anyway, this tutorial will be about deployment for php projects (Laravel 4 in particular) on OS X. I’m assuming you already have a webserver up & running (I’m using MAMP).

1) Install Jenkins

Go to http://jenkins-ci.org/ and install Jenkins for Mac OS X, make sure to use seperate new user. Here’s a great tutorial about this: http://colonelpanic.net/2011/06/jenkins-on-mac-os-x-git-w-ssh-public-key/

Addons:
– Jenkins in your dock: https://github.com/stisti/jenkins-app
– JenkinsMobi (iOS app): http://hudson-mobi.com/

2) Configure Jenkins

I strongly recommend you to follow this tutorial http://jenkins-php.org/ as it has almost everything documented for deploying php apps through Jenkins. My setup is actually based on this documentation.

Download the Jenkins plugins listed on the jenkins-php.org website. I’m using these:
– Jenkins Mailer Plugin
– External Monitor Job Type Plugin
– Ant Plugin
– Static Analysis Utitlities
– Checkstyle Plug-in
– Credentials Plugin
– Jenkins CVS Plug-in
– Duplicate Code Scanner Plug-in
– Jenkins Email Extension Plugin
– FTP publisher plugin
– Jenkins GIT client plugin
– Jenkins GIT plugin
– GitHub API Plugin
– Github plugin
– HTML Publisher plugin
– Jenkins JDepend Plugin
– Plot plugin
– PMD Plug-in
– Publish Over FTP
– xUnit Plugin

3) Configure a new project

Install the jenkins-php’s job template tutorial. When you want to create a new project, simply copy the job template project and modify it as you want.

4) Connect your git repo

Connect your git repo to jenkins. Make sure to use the git protocol (git@github.com:username/repo.git) if you setup key pairs. If you’re using the http:// github url it will keep asking for credentials even though your key pairs are correctly installed.

5) Install Composer

Use this tutorial to install Composer: http://getcomposer.org/doc/01-basic-usage.md#installation

And put it in your bin directory so every user can use this great piece of software:

cp composer.phar /usr/local/bin/composer

If you’re using composer you will at one point notice it will clone your depency repo’s using git everytime you build your application. And this gave me some Jenkins problems.. Even though the normal ‘composer update’ worked like a charm under my jenkins user, Jenkins itself was giving problems.

[exec] [RuntimeException]
[exec] Failed to clone http://github.com/nicolas-grekas/Patchwork-UTF8.git, git was not found, check that it is installed and in your PATH env.
[exec]
[exec] sh: git: command not found

more @ http://jenkins.361315.n4.nabble.com/git-not-found-with-jenkins-composer-php-td4660806.html

To fix this, go to http://localhost:8080/configure -> Global configuration -> Environment variables
And add this:
name = PATH
value = /usr/local/git/bin:$PATH

As you can see in the following picture, composer is now fully working in our build process:
1JMuzxRzPabYasaXePdvw9d6GXHitPljLOciovw

6) Install some additional PHP packages

Now of course we want code statistics, automated unit testing, auto generated API documentation, coverage reports, etc so we need to install some extra tools:

pear (http://pear.php.net/)
Follow this quick guide to install pear: https://gist.github.com/macek/1301527

phpdox (https://github.com/theseer/phpdox)

sudo pear config-set auto_discover 1
sudo pear install pear.netpirates.net/phpDox-0.4.0

phpunit (http://www.phpunit.de/manual/3.0/en/installation.html)

sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit

phploc (https://github.com/sebastianbergmann/phploc)

sudo pear config-set auto_discover 1
sudo pear install pear.phpunit.de/phploc

pdepend (http://pdepend.org/documentation/getting-started.html)

sudo pear channel-discover pear.pdepend.org
sudo pear install pdepend/PHP_Depend-beta

phpcb

sudo pear channel-discover pear.phpqatools.org
sudo pear install --alldeps phpqatools/PHP_CodeBrowser

7) Create your build file

Next we create our build.xml file and we make sure it’s executed correctly by Jenkins (check Project -> Building steps). Put this file in your /jobs/PROJECT directory.

Here’s mine: http://paste.laravel.com/mLw

Note: you can test the build file manually by executing this command. So no need to build via Jenkins and download 24 composer repo’s before it starts executing the ant build file.

ant -f build.xml -v

You will also need some additional XML config files:

PROJECT/phpcs.xml -> http://paste.laravel.com/mLB

PROJECT/phpdox.xml -> http://paste.laravel.com/mLA

PROJECT/phpmd.xml -> http://paste.laravel.com/mLz

You will also have to alter your Laravel’s phpunit.xml file: http://paste.laravel.com/mLC (the one in your root folder)

8) Build your application

Now try to build your application through Jenkins. Enjoy!

Here’s how it should look like: http://paste.laravel.com/mMn

And some fancy screenshots:
1FxhZRcTJZS4fgVepTvJLoAUx_VwyqjI0xBQTBw

1BWoJILiDN0QjSfOlgQmSwLRB3VsH0FOt58ym3g

These are just some Jenkins screenshots.. our build file is also generating documentation, code coverage, getc which you can find in PROJECT/workspace/build/ and PROJECT/build

Interesting links:
http://jenkins-php.org/
http://erichogue.ca/2011/05/php/continuous-integration-in-php/

PHPBenelux Conference 2013

My first ‘official’ post (well actually my second post after Hello World) was a review of the PHP Benelux 2012 conference so why don’t we make a tradition out of it?
I must say, the conference is getting better and better each year with lots of interesting speakers, tutorials, visitors, and of course the enjoyable socials with lots of free Belgian beer!

PHP Benelux 2013 after movie:

And of course the by now famous stressball fight:

DirectAdmin API packagist/composer package

Because Laravel Four is trading in bundles for Composer I decided it’s time to create a package for this. After all, it’s a very handy library!

You can find it here:
https://packagist.org/packages/directadmin/directadmin

And here:
https://github.com/kryap/php-directadmin

Test case:

$da = new \DirectAdmin\DirectAdmin();
$da->connect('domain.be', 2222);
$da->set_login('username', 'password');
 
$da->set_method('get');
$da->query('/CMD_API_SHOW_DOMAINS');
$da = $da->fetch_body();
 
var_dump($da);

Again, make sure you read the DirectAdmin API docs @ http://www.directadmin.com/api.html