Skip to content

Understanding Mod Groups for AB Testing in Joystick

Joystick uses a simple and reliable method to assign users to groups for AB testing and staged rollouts. This process ensures that each user is consistently assigned to the same group over time. Here's how it works:

How Modulo Numbers Are Derived

  1. User Identifier (u Parameter):
  2. Every request sent to Joystick includes a unique identifier for the user, called the "u" parameter. This could be a user ID, integer, GUID, or any other unique string that identifies the user.

  3. Generating a Stable Integer:

  4. Joystick uses a hashing algorithm called Murmur to convert the "u" parameter into a stable integer. This means that the same "u" value will always produce the same integer.

  5. Modulo Operation:

  6. The stable integer is then divided by 1000, and the remainder (known as the modulo) is taken. This results in a number between 0 and 999.

Why This Matters

  • Consistency: The same user will always fall into the same group, ensuring reliable test results.
  • Scalability: By using numbers between 0 and 999, you can easily divide your audience into up to 1000 segments, each representing 0.1% of your audience.
  • Flexibility: You can define ranges of these numbers (e.g., 0-99 for 10% of users) to control how much of your audience is exposed to a specific feature or test.
  • Precise Testing: You can expose different groups for different tests for features so you don't over test a particular group of users. (e.g. use group 0-199 for testing feature A in January, then use group 200-499 testing feature B in February.)
  • Staged Rollouts: This method allows for gradual rollouts of features, where you can start with a small percentage of users and increase it over time.

Example

If you send a request with user param "u" value of "user123":

Request Body
{
  "u": "user123",
  "p": {
    // Optional segmentation parameters
  }
}
  1. The "u" value ("user123") is hashed using Murmur, producing a stable integer (e.g., 456789).
  2. The integer is divided by 1000, and the remainder is calculated: 456789 % 1000 = 789.
  3. The user is assigned to the group corresponding to the modulo value 789.

If you define a Dynamic Content Definition as follows...

Dynamic Content Definition
[
  {
    "expression": "location = 'ch'",
    "name": "offer_title_test",
    "groups": [
      {
        "variantName": "variant_a",
        "mod": [
          [ 0, 199 ]
        ],
        "values": {
          "LK-OfferTitle": "Extra Special Offer"
        }
      },
      {
        "variantName": "variant_b",
        "mod": [
          [ 700, 799 ]
        ],
        "values": {
          "LK-OfferTitle": "Something Amazing Just For You!"
        }
      }
    ]
  }
]
The user with a modulo value of 789 will be included in the variant_b, and get the value "Something Amazing Just For You!" for the LK-OfferTitle parameter.

This process ensures that every user is consistently assigned to the same group, making it easy to manage audience segmentation and AB testing.

Learn More

For more information on how to set up and use dynamic content in Joystick, check out our comprehensive guides for Segmentation and AB Testing: