Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs of code experiments #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions documentation/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,32 @@ If you need to be really granular, decimal numbers are also supported, like `33.

#### Code-level experiments

These experiments are about testing different variants of components (≠ style and logic).
When the experiment will be run the body will have a class that reflects the variant of the session.
To make the component work according to the experiment it is necessary to add logic checking if body class includes "variant" or "control".
If "control" is included the component will need to run the control version of the code, otherwise the challenger version.

Note that the above assumes you have different content variants to serve, but if you want to run a pure code-based A/B Test, this is also achievable via:

| Metadata | |
|---------------------|-----------|
| Experiment | Hero Test |
| Experiment Variants | 2 |


```js
export default function decorate(block) {
if (document.body.classList.contains('variant-challenger-1')) {
// experiment variant 1
}
else if (document.body.classList.contains('variant-challenger-2')) {
// experiment variant 2
} else {
// control variant
}
```


This will create just 2 variants, without touching the content, and you'll be able to target those based on the `experiment-hero-test` and `variant-control`/`variant-challenger-1`/`variant-challenger-2` CSS classes that will be set on the `<body>` element.


Expand Down