A/B Testing: Configuration¶
This page describes the service-specific configuration required to make the A/B test work. Both services must be configured correctly and in sync for the test to function as intended.
Back to overview
For the high-level overview of how the A/B test works, see A/B Testing Overview.
brekz-prestashop¶
brekz-prestashop is responsible for two things:
- Setting the
AB_templatingcookie server-side to assign visitors to a test group. - Rewriting links client-side so that variant B visitors are sent to the
www2.*subdomain.
Cookie Assignment¶
The AB_templating cookie is set server-side in PHP. Visitors assigned to variant B receive the value B.
The cookie is set within the root web/index.php PrestaShop dispatch file.
JavaScript Link Manipulation¶
A JavaScript module in brekz-prestashop reads the AB_templating cookie and rewrites links when the visitor is in variant B.
Behavior:
- Runs on every page load within brekz-prestashop.
- Reads the
AB_templatingcookie value. - If the value is
B, it finds all links matching the Category page 2012 variant URL pattern. - Rewrites those links to use the
www2.*subdomain instead ofwww.*.
Example rewrite:
Before: https://www.brekz.nl/categorie/honden-speelgoed
After: https://www2.brekz.nl/categorie/honden-speelgoed
This logic is implemented in the web/themes/brekz-2017/resources/js/global.js JavaScript file.
Targeted link patterns:
The script specifically targets URLs that correspond to Category page 2012 variant pages. Other page types (PDP, checkout, account, etc.) are not rewritten and remain on brekz-prestashop.
It fetches a JSON file which contains all Category page 2012 variant page URL's for the specific shop and language.
fetch('/cache/page_index_' + id_shop + '_' + id_lang +'.json')
brekz-website¶
brekz-website is responsible for serving pages to variant B visitors arriving on the www2.* subdomain.
Environment Variables¶
Two .env variables control the A/B test behaviour in brekz-website:
| Variable | Example value | Description |
|---|---|---|
ABTEST_CATEGORY2012_ENABLED |
true |
Enables brekz-website to serve Category page 2012 variant pages. Set to false to disable without removing the configuration. |
ABTEST_CATEGORY2012_HOSTNAME |
www2.brekz.nl |
The hostname brekz-website uses to identify incoming variant B traffic. Requests on this hostname are handled as Category page 2012 variant pages. |
Example .env entry:
# A/B Testing — Category page 2012 variant
ABTEST_CATEGORY2012_ENABLED=true
ABTEST_CATEGORY2012_HOSTNAME=www2.brekz.nl
Per-country configuration
ABTEST_CATEGORY2012_HOSTNAME accepts a single hostname. When expanding the test to additional countries (e.g. www2.brekz.be), verify how brekz-website handles multi-country hostname configuration and update accordingly.
Configuration Checklist¶
Use this checklist when enabling the A/B test for a new country or page type:
-
AB_templatingcookie assignment logic covers the new country/domain - JavaScript link manipulation is updated to include the new country's domain
-
www2.*subdomain is provisioned and routed to brekz-website (DNS + Cloudflare) -
ABTEST_CATEGORY2012_ENABLED=trueis set in brekz-website.env -
ABTEST_CATEGORY2012_HOSTNAMEis set to the correctwww2.*hostname for the country - End-to-end test: visit
www.*, verify cookie is set toB, click a category link, verify redirect towww2.*, verify page renders correctly