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

# Implement A/B Testing

A/B testing allows you to compare 2 versions of a feature, experience, or campaign to see which performs better based on player behavior. This method helps optimize performance by revealing what drives player engagement and revenue.

You can use A/B testing in both the web store and checkout to evaluate product features, creative assets, pricing strategies, or promotional campaigns.

## How it works

1. Divide players into 2 groups and show each group a different experience, such as a background, price, or value.
2. Tag players with a group-specific attribute using the [Personalization API](/../../api-reference/webstore/personalization/introduction) or [Create Checkout Session API](/../../api-reference/checkout/checkout-session/create-checkout-session).
3. Track performance in the **A/B Test** tab on the **Analytics** page in the Publisher Dashboard to see which offer performs best.

The following example shows how to set up and analyze a pricing test.

## Sample use case

Suppose you're launching a Halloween campaign and want to test 2 pricing strategies, Buy 1 Get 1 Free and 50% Off to see which performs best. The original offer is \$10 for 100 coins.

### Step 1 | Define your test groups

Divide your players into 2 groups:

* **Group A:** Buy 1 Get 1 Free — \$10 for 200 coins
* **Group B:** 50% Off — \$5 for 100 coins

### Step 2 | Create the offers in the web store

Create the 2 offers in your web store and ensure each player group sees the correct one.

The setup differs depending on whether you use the Appcharge web store or a custom web store.

#### Appcharge web store

If you have the Appcharge web store:

1. Use the [Offers API](/../../api-reference/webstore/offers-v2/introduction) to create the 2 offers. In this example, we create a special offer by calling [Create Special Offer](/../../api-reference/webstore/offers-v2/special-offers/create-special-offer):

   <br />

   <br />

   <Accordion title="Offer 1: Group A">
     ```js theme={"system"}
     {
       "publisherOfferId": "offer1",
       "productsSequence": [
         {
         "index": 0,
         "products": [
             {
             "publisherProductId": "22356758900ff",
             "quantity": 200 // 200 coins
             }
         ],
         "priceInUsdCents": 1000 // $10
         }
       ]
     }
     ```
   </Accordion>

   <Accordion title="Offer 2: Group B">
     ```js theme={"system"}
     {
       "publisherOfferId": "offer2",
       "productsSequence": [
         {
         "index": 0,
         "products": [
             {
             "publisherProductId": "22356758900ff",
             "quantity": 100 // 100 coins
             }
         ],
         "priceInUsdCents": 500 // $5
         }
       ]
     }
     ```
   </Accordion>

2. When a player from each group logs in to the web store, call the [Personalization API](/../../api-reference/webstore/personalization/introduction) to display the correct offer and tag the player with their group.

   <br />

   <br />

   <Accordion title="Group A">
     ```js theme={"system"}
     {
       "offers": [
         {
           "publisherOfferId": "offer1",
           "productsSequence": [
             {
               "index": 0,
               "products": [
                 {
                   "publisherProductId": "22356758900ff",
                   "quantity": 200, // 200 coins
                   "priority": "Main"
                 }
               ]
             }
           ]
         }
       ],
       "attributes":
       {
         "price_test": "A" // Group A
       }
     }
     ```
   </Accordion>

   <Accordion title="Group B">
     ```js theme={"system"}
     {
       "offers": [
         {
           "publisherOfferId": "offer2", 
           "productsSequence": [
             {
               "index": 0,
               "products": [
                 {
                   "publisherProductId": "22356758900ff",
                   "quantity": 100, // 100 coins
                   "priority": "Main"
                 }
               ]
             }
           ]
         }
       ],
       "attributes":
       {
         "price_test": "B" // Group B
       }
     }
     ```
   </Accordion>

   <Note>
     If you have an Appcharge web store, skip Step 3 and go directly to Step 4.
   </Note>

#### Custom web store

If you have a custom web store, create 2 separate offers in your own system and implement display logic so each group sees the correct one.

You don’t need to call the Personalization API in this step. Instead, proceed to Step 3, where you’ll pass the player’s group attribute when creating the checkout session.

### Step 3 | Update prices in the checkout

<Note>
  This step is only relevant for custom web stores.
</Note>

When a player clicks an offer in the web store, call the [Create Checkout Session API](/../../api-reference/checkout/checkout-session/create-checkout-session) with both the pricing and group assignment.

<Accordion title="Group A">
  ```js theme={"system"}
  {
    "priceDetails.price": 10,
    "items.quantity": 200,
    "attributes": {
      "price_test": "A"
    }

  }
  ```
</Accordion>

<Accordion title="Group B">
  **Group B:**

  ```js theme={"system"}
  {
    "priceDetails.price": 5,
    "items.quantity": 100,
    "attributes": {
      "price_test": "B"
    }
  }
  ```
</Accordion>

### Step 4 | Compare results in the Publisher Dashboard

[Analyze the results of the A/B test](./../publisher-dashboard/view-analytics#a%2Fb-test) and review which group generated more revenue. Use these insights to decide which pricing strategy to roll out, or to refine future campaigns.
