Zope Hints


Here is what you need to do to hand out two versions of a page (typically a folder with the default index_html method). We are using a cookie which we call "split_test". Here is how you render one of two versions of the same page with the following index_html DTML Method (index_b being the default version):

<dtml-if expr="REQUEST.has_key('split_test') and REQUEST.split_test =='a'">
<dtml-var index_a>
<dtml-var index_b>

The cookie can be set according to whatever criterion that the A/B-Test is intended for. One of the simplest ways is to let the viewer choose by calling the following Script (Python) from an appropriate URL which links right back to the index_html page next to the script. In this case we also decide to let the cookie expire after one day.

# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST

RESPONSE.setCookie('split_test', 'a', path='/', max_age=30*24*3600)
return ''

Switching back to 'b' is analogous.

Elmar Heeb, 2009/07/28 13:24:0.773011 GMT+2