Goal
Create a multivariate test (MVT) experiment with multiple sections and variations, then set custom (non-equal) traffic allocation across those variations. For an overview of MVT concepts (sections, variations, and combinations) and how to configure traffic allocation in the Kameleoon app, read Set up multivariate tests.Requirements
access token
siteId
siteId directly in code with the siteCode by calling the get a site by code endpoint, or find it in the app by following the steps in Create a new experiment.
Key concepts
The reference variation
Kameleoon automatically adds one reference variation to each section you submit. The reference appears in the response asvariationId: "0" within that section’s allocation entries.
If you submit your own variation named Original, Kameleoon creates it as a separate, additional variation. It doesn’t identify or replace the generated reference. Only submit an explicit Original variation if you intend to test two distinct baseline variations in the same section.
Client-submitted IDs are temporary
ThesectionId and variation id values you submit in mvtVariations only link entries within that single request: they connect each mvtAllocationSettings allocation entry to the correct section and variation before Kameleoon generates permanent IDs. Use any integers that are convenient for you.
Kameleoon discards the submitted values and replaces them with its own generated sectionId and variationId values. Use the generated values (returned in the response and by a later GET request) for every subsequent request. The response doesn’t include the variation names you submitted, only the generated IDs. If you need to confirm which generated ID corresponds to which submitted name, check the experiment in the Kameleoon app.
Section IDs versus combination IDs
Kameleoon generates two distinct sets of IDs for an MVT experiment:- Section and variation IDs identify one variation within one section. Use these in
mvtAllocationSettings.sectionsAllocations. - Combination IDs identify one full combination of variations, one per section, shown to exposed visitors. Kameleoon generates every possible combination as the Cartesian product of all sections’ variations (including the reference in each section) and returns the combination IDs in the top-level
variationsarray and as keys in thedeviationsmap. Use these inmvtAllocationSettings.combinationsAllocations.
sectionsAllocations and combinationsAllocations use the same allocation item structure (allocationPart, checked, locked, sectionId, variationId), so choose only one method:
- Populate
sectionsAllocationsto allocate traffic by individual variation within each section. Kameleoon derives each combination’s share from the section-level values. - Populate
combinationsAllocationsto allocate traffic directly to specific combinations.
combinationsAllocations in the creation request. Retrieve the generated combination IDs with a GET request, then set combinationsAllocations in a follow-up PATCH request, following the same pattern used for sectionsAllocations in this tutorial.
Steps
1. Create the experiment
Endpoint:
Example:
sectionId and variationId values (4451, 4452, 1351293-1351296), added a reference variation (variationId: "0") to each section, and replaced the submitted allocation with an equal 0.33333334 share, resetting locked to false. Kameleoon preserves exposedPart as submitted. Continue to the next step to set the allocation you want.
2. Retrieve the generated IDs
If you didn’t capture the generated IDs from the create response, retrieve them with aGET request.
Endpoint:
mvtAllocationSettings.sectionsAllocations array shown in step 1, with the generated sectionId and variationId values you need for the next step.
3. Set custom traffic allocation
Endpoint:mvtAllocationSettings again, this time using the generated sectionId and variationId values from step 2.
Example:
locked stays true. A subsequent GET request confirms the same result.
4. Verify the experiment
Go to the Experiments Dashboard in the Kameleoon app and open the experiment to confirm the sections, variations, and traffic allocation match what you configured.Known limitations
- Deleting large MVT experiments can time out.
DELETE /experiments/{experimentId}can return a504 Gateway Timeouterror when the experiment has many combinations. A timeout doesn’t necessarily mean the delete failed: send aGETrequest for the same experiment ID to confirm whether it still exists before retrying the delete.