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:

{
    "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:

Last updated

Was this helpful?