> For the complete documentation index, see [llms.txt](https://docs.abtasty.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abtasty.com/server-side/command-line-interface/resource-loader/web-experimentation.md).

# Web Experimentation

Resource Loader for Web experimentation

The **Resource Loader in Web Experimentation** organizes experimentation and personalization data in a hierarchical JSON structure. A Campaign contains one or more Variations, and each Variation contains one or more Modifications. This nested design is intentionally kept shallow – only **Campaign → Variation → Modification** is allowed – to maintain readability and manageability. Deeply nested levels (e.g. a further `modification_code` level) are avoided to prevent overly verbose data structures. Uncommon or rarely used properties are simplified or omitted to streamline the schema. Overall, this schema is designed to be adaptable to changes while remaining version-controlled.

* **Campaign:** A campaign represents an experiment or personalization activity (for example, an A/B test or personalization campaign). It defines the context (such as the test name, type, target URL, status, etc.) and contains one or more variations.
* **Variation:** A variation is an alternate version within a campaign. For an A/B test, the variations could be the control (original) and one or more test versions. Each variation can have associated modifications that implement the changes for that version of the campaign.
* **Modification:** A modification is a specific change or piece of content to apply on the page. It is typically a code snippet (JavaScript or CSS) that alters the page for a given variation (for example, changing text, hiding an element, or running a script).

In addition, the resource loader supports organizational and targeting resources:

* **Folder:** A folder is used to organize campaigns into groups. It’s not part of the campaign→variation→modification hierarchy (folders exist at the account level), but folders help categorize campaigns for easier management.
* **Audience:** An audience defines a set of targeting rules (such as user attributes or browsing conditions) that determine which visitors are included or excluded. Audiences are reusable and can be attached to campaigns to control who sees the campaign. The audience schema includes nested rule definitions (targeting groups and conditions) to allow complex targeting logic.

Each resource type (Campaign, Variation, Modification, Folder, Audience) is defined with its own schema, including its fields, nested structure, and relationships. Below, we document each resource in detail with high-level explanations, field definitions, example payloads, and example responses.

Resource Loader file example:

```json
{
    "version": 1,
    "resources": [
        {
            "type": "folder",
            "$_ref": "f1",
            "action": "create",
            "payload": {
                "name": "Summer 2025"
            }
        },
        {
            "type": "audience",
            "$_ref": "a1",
            "action": "create",
            "payload": {
                "name": "Segment",
                "description": "description_1",
                "hidden": false,
                "allow_duplicated_config": true,
                "groups": [
                    [
                        {
                            "operator": "or",
                            "mutation_observer": false,
                            "type": "ACTION_TRACKING",
                            "conditions": [
                                {
                                    "include": true,
                                    "value": "hello2025"
                                }
                            ]
                        },
                        {
                            "operator": "auto",
                            "mutation_observer": false,
                            "type": "SESSION_NUMBER",
                            "conditions": [
                                {
                                    "condition": 1,
                                    "include": true,
                                    "value": 60
                                }
                            ]
                        }
                    ]
                ]
            }
        },
        {
            "type": "campaign",
            "$_ref": "c1",
            "action": "create",
            "payload": {
                "name": "Holiday Promo",
                "description": "Winter discounts",
                "url": "https://example.com",
                "type": "ab",
                "status": "pause",
                "labels": [
                    "chadi.laoulaou",
                    "SP"
                ],
                "code": "console.log('campaign global code!')",
                "source_code": "",
                "folder_id": "$f1.id",
                "campaign_targeting": {
                    "segment_ids": [
                        "$a1.id"
                    ],
                    "url_scopes": [
                        {
                            "condition": "IS",
                            "value": "https://example.com"
                        }
                    ],
                    "selector_scopes": [
                        {
                            "condition": "IS_SELECTOR_CLASS",
                            "value": ".h1"
                        },
                        {
                            "condition": "IS_NOT_SELECTOR_ID",
                            "value": "#1234"
                        },
                        {
                            "condition": "IS_NOT_SELECTOR_CLASS",
                            "value": ".#blue"
                        }
                    ],
                    "code_scope": {
                        "value": "console.log(\"hello world\");"
                    },
                    "element_appears_after_page_load": false,
                    "targeting_frequency": {
                        "type": "regular",
                        "unit": "day",
                        "value": 20
                    }
                }
            },
            "resources": [
                {
                    "type": "variation",
                    "$_ref": "v1",
                    "action": "create",
                    "payload": {
                        "name": "Variation A",
                        "description": "Define variation description",
                        "traffic": 14,
                        "code": {
                            "js": "alert('Variation A')",
                            "css": "p {color: red; text-align: center;}"
                        }
                    },
                    "resources": [
                        {
                            "type": "modification",
                            "$_ref": "m1",
                            "action": "create",
                            "payload": {
                                "name": "modification 1",
                                "selector": "#main .text-center a",
                                "type": "js",
                                "code": "<h1>Click Here !</h1>"
                            }
                        }
                    ]
                },
                {
                    "type": "variation",
                    "$_ref": "v2",
                    "action": "create",
                    "payload": {
                        "name": "Variation B",
                        "traffic": 14,
                        "code": {
                            "js": "document.querySelector('.btn').textContent = 'CLICK HERE';"
                        }
                    }
                }
            ]
        },
        {
            "type": "variation",
            "$_ref": "v3",
            "$_parent_id": "$c1.id",
            "action": "create",
            "payload": {
                "name": "Variation C",
                "code": {
                    "js": "console.log('Variation C')",
                    "css": "p {color: purple; text-align: center;}"
                }
            }
        },
        {
            "type": "modification",
            "$_ref": "m2",
            "action": "create",
            "$_parent_id": "$v1.id",
            "payload": {
                "name": "modification 2",
                "campaign_id": "$c1.id",
                "selector": "#main",
                "type": "js",
                "code": "console.log('hello people!')"
            }
        }
    ]
}
```

Resources link:

* [Modification](https://docs.abtasty.com/server-side/command-line-interface/resource-loader/web-experimentation/modification.md)
* [Variation](https://docs.abtasty.com/server-side/command-line-interface/resource-loader/web-experimentation/variation.md)
* [Campaign](https://docs.abtasty.com/server-side/command-line-interface/resource-loader/web-experimentation/campaign.md)
* [Folder](https://docs.abtasty.com/server-side/command-line-interface/resource-loader/web-experimentation/folder.md)
* [Audience](https://docs.abtasty.com/server-side/command-line-interface/resource-loader/web-experimentation/audience.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.abtasty.com/server-side/command-line-interface/resource-loader/web-experimentation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
