> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# ABTest- (A/B tests)

> The tags for A/B tests in the template: serving test cases, enclosing variants and counting conversions.

With an A/B test, the shop serves the same page in several variants and measures which of them leads to the goal more often. A test is created in the A/B test manager; in the template, the tags with the prefix `ABTest-` determine what a visitor actually gets to see.

Three tags are sufficient for this. `ABTest-active()` switches on the test area in the first place, `ABTest-caseA` to `ABTest-caseJ` enclose the individual variants, and `ABTest-TriggerConversion()` reports the success back on the target page.

| Tag | Single tag | Area tag | Negative area tag | Loop tag |
| - | - | - | - | - |
| `ABTest-active()` | – | yes | yes | – |
| `ABTest-caseA` to `ABTest-caseJ` | – | yes | yes | – |
| `ABTest-TriggerConversion()` | yes | – | – | – |

All three tags are permitted in all templates.

Guide: A/B test

## The structure in the template

The two area tags always belong nested inside each other. On the outside is `ABTest-active()` with the test ID, on the inside one area for each test case created in the A/B test manager.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{ABTest-active(startseite-banner)}

   {ABTest-caseA}
      <!-- Variante A: der bisherige Banner -->
   {/ABTest-caseA}

   {ABTest-caseB}
      <!-- Variante B: der neue Banner -->
   {/ABTest-caseB}

{/ABTest-active(startseite-banner)}

{!ABTest-active(startseite-banner)}
   <!-- Läuft kein Test, wird der reguläre Banner ausgespielt -->
{/!ABTest-active(startseite-banner)}
```

> [!WARNING]
>
> The negative area is part of it. Without it, nothing at all appears at this point as soon as the test has ended or its ID no longer exists. What should be visible outside the test phase must therefore be explicitly included in the template.

> [!NOTE]
>
> Upper and lower case of the tag names and the test ID do not matter. `ABTest-active` and `abtest-Active` lead to the same result. Nevertheless, stick to one spelling, otherwise a later search in the template directory will not find all occurrences.

## ABTest-active()

The area is displayed if the A/B test with the specified ID is currently active. The test ID is passed as a parameter and must match the ID from the A/B test manager exactly.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{ABTest-active(startseite-banner)}
   Dieser Bereich wird angezeigt, wenn der A/B-Test aktiv ist.
{/ABTest-active(startseite-banner)}

{!ABTest-active(startseite-banner)}
   Dieser Bereich wird angezeigt, wenn der A/B-Test nicht aktiv ist.
{/!ABTest-active(startseite-banner)}
```

### How the test case is assigned

The shop does not assign the test case randomly. When the test is first called in a session, it determines which test case has had the fewest views so far and assigns that one. This distributes visitors evenly across the variants, without one variant ending up with significantly less data than the other.

Counting is done per subshop. A test running in several subshops therefore balances its distribution in each subshop separately.

> [!NOTE]
>
> The view is only counted by the positive area `{ABTest-active(…)}`, not by the negative one. A template that works exclusively with `{!ABTest-active(…)}` therefore delivers no data to the test.

## ABTest-caseA to ABTest-caseJ

The area is displayed if the corresponding test case is assigned to this visitor. For each test case created in the A/B test manager, a separate area belongs in the template, from `ABTest-caseA` up to a maximum of `ABTest-caseJ`. More than ten test cases are not possible.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{ABTest-active(startseite-banner)}

   {ABTest-caseA}
      Variation für den Testfall A
   {/ABTest-caseA}

   {ABTest-caseB}
      Variation für den Testfall B
   {/ABTest-caseB}

{/ABTest-active(startseite-banner)}
```

> [!WARNING]
>
> These tags are only valid within the enclosure of `ABTest-active()`. If they are placed outside it, the tag is invalid and is not evaluated as an enclosure.

> [!NOTE]
>
> The letter in the tag corresponds to the order of the test cases in the A/B test manager: the first test case is A, the second B, and so on. It is independent of how you named the test case there. If a test case is deleted in the manager, the test cases behind it move up by one letter. In this case, check the assignment in the template, otherwise variant B will suddenly show the content of C.

## ABTest-TriggerConversion()

Counts a conversion for the test with the specified ID. The tag belongs on the page whose call is counted as a success.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
~ABTest-TriggerConversion(startseite-banner)~
```

> [!NOTE]
>
> The tag is only needed if "By tag on target page" has been set as the conversion goal in the A/B test manager. For the other goals, the shop counts itself, and the tag then has no effect.

> [!WARNING]
>
> The test ID must match the ID from the A/B test manager exactly. A typo goes unnoticed in the page source code but distorts the evaluation.

For verification, the tag writes an HTML comment into the page when a test ID is found:

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<!-- ABTest triggered -->
```

It is visible in the source code of the target page but not in the browser. This lets you check whether the tag is in the right place without waiting for the evaluation in the A/B test manager.

## Viewing variants specifically

In test mode, you can call up each test case yourself instead of waiting for the shop to assign it. To do this, the shop is called with three parameters:

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
?test=on&ab-test-id=<Test-ID>&ab-test-case=<A bis J>
```

| Parameter | Meaning |
| - | - |
| `test=on` | switches on test mode |
| `ab-test-id` | the ID of the test whose variants you want to view |
| `ab-test-case` | the letter of the desired test case |

With `ab-test-id=off` you end the A/B test mode again without leaving the general test mode.

> [!NOTE]
>
> Calls in test mode are not included in the evaluation. Neither views nor conversions are counted, so you can switch between the variants as often as you like.

> [!WARNING]
>
> Test mode only takes effect if A/B tests are enabled for the shop and the specified test ID actually exists. If the ID is incorrect or the letter is not a valid test case, test mode silently remains unset and you see the regularly assigned variant. In that case, check the spelling of the ID first.

> [!NOTE]
>
> Unlike in live operation, test mode only checks whether the test has been created, not whether it is currently running. You can therefore view variants before the start and after the end of a test.

## Related topics

* Guide: A/B test
* Guide: Enabling and disabling shop test modes


## Related topics

- [A/B test](https://dokumentation.websale.de/en/v8s/funktionen-zur-shop-optimierung/a-b-test.md)
- [Enabling and disabling shop test modes](https://dokumentation.websale.de/en/v8s/domains/testmodi-des-shops-ein-ausschalten.md)
- [Special online services](https://dokumentation.websale.de/en/v8s/online-servicebereich/spezielle-online-dienste.md)
- [TestMode](https://dokumentation.websale.de/en/frontend/referenz/aktionen/testmode.md)
- [$wsTestMode - Test mode](https://dokumentation.websale.de/en/frontend/referenz/module/wstestmode.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.