Company
Date Published
Author
Salma Alam-Naylor
Word count
1666
Language
English
Hacker News points
None

Summary

In this post, the author discusses how to run an A/B test on a more granular level than just page layouts, without creating new page layouts and rewriting URLs. The goal is to allow content authors to stay in control of the content while enabling developers to write code for the test. This can be achieved by using a Content Management System (CMS) with separate areas or spaces that can be fetched with different API keys and access tokens. The author provides an example of how to A/B test messaging on a home page hero banner, using Netlify Edge Functions, Cloudflare's HTMLRewriter, and environment variables. The code example demonstrates how to assign users to test buckets using browser cookies, fetch data from the CMS at runtime, modify the HTTP response using HTMLRewriter, and track test variants in analytics tools. The author also provides bonus content on using environment variables to control which A/B tests are running.