I've been looking around for a good way to do A/B split-testing with Drupal for a while and I've never been satisfied with the available options, so I decided to see what I could do with cck_redirection. Here is what I came up with:

This hack allows you to specify multiple redirection destination URLs instead of just one. The URL to redirect to will be selected at random. You can specify as many URLs as you want so you can do A/B split testing or n-way testing of many destinations. Since it is based on cck_redirection, you can redirect to any view, node type or even another site altogether.

Here is how the hack works: first, in cck_redirection_form_alter, I commented out the code that disables multiple fields support. This allows you to enter multiple redirection URLs.

Then, in _cck_redirection_redirect, it checks $field['multiple'] and if it is greater than 1, calculates a random value used to select which URL is shown. A static counter is used to match the URL to the random value. If the count doesn't match the random value, it just returns without doing anything.

This is a little hacky, but I'm pretty ignorant of CCK - is there a better way to do this?

CommentFileSizeAuthor
split_test_hack.patch3.33 KBkeathmilligan

Comments

Morris Singer’s picture

It's an interesting idea. I can't think of many applications for it though. Maybe if we could do something where the content creator could pick how a URL gets chosen from multiple values, and there could be other options. I am not sure what they'd be, but I'm just throwing out the idea. Hardwiring the selection to random seems a bit constrained in application.

giorgio79’s picture