Boosting Conversion Rates and User Experience: A Deep Dive into A/B Testing for React Web and React Native

Yunus Emre Tat26 Jun 2023

Problem

The TrendyolAds team builds the advertising product that sellers on Trendyol use to promote their listings, on web and in a mobile app. They want to test interface changes: button placement and shape, informational messages and action buttons for ad status. The article describes the in-house mechanism they built for this: random assignment of users to variants, a stored assignment, and a config file to start, pause and delete experiments.

Example from the article: a seller's ad listing page where two variants of the "create new ad" button are shown to different users in the mobile client.

Solution in brief

Each user gets a random number from 0 to 100 per experiment, stored in one cookie (web) or local storage (mobile). The UI code compares the number with a threshold or range to choose the variant. A config file lists experiments with a running or paused status, and a small service assigns, stores and cleans up the numbers.

Questions this case answers
  • How to randomize users into variants on the client side and keep their assignment stable across sessions when no experimentation platform is available
  • How to run UI A/B tests in a React web and React Native app without a third-party experimentation tool?
  • How to keep a user in the same variant across visits when assignment happens on the client?
  • How to pause or retire an experiment through a config file without changing application code?

Tools and methods

  • A/B test — compare variants of a UI element across randomly assigned users.
  • Experiment service (TypeScript class) — initializes experiments, assigns scores, reads and writes the storage key.
  • Cookie / local storage — keeps the assignment between visits.
  • React — renders the control or the new component depending on the stored score.
Continue reading — it's free

Google or a one-time email code. No password.