User Object

The User attibute contains the ID and all live experiments and test groups

Intelligems ID

window.igData?.user.igId (string)

Example
let igId = window.igData?.user.igId;

console.log(igId);

"ig_71e855a9313945b63eb35e0abd5b63361d48"

Experiments

window.igData?.user.getExperiments() (Array<experiment>)

This function returns all experiments that are currently in scope for this user. The logic underneath takes into account whether or not an experiment is active, the user is eligible, and the experiment should run on this page (see Audience and Page Targeting). If you are previewing an experiment using the intelligems Preview mode, only that experiment will be returned here.

Example

console.log(window.igData?.user.getExperiments());

[
    {
        "id": "8bce9d31-cd20-4f4a-a070-a6970c7e9803",
        "name": "Price Test",
        "isPreview": true
    }
]

Test Groups

Get All Test Groups in the Experiment

window.igData?.user.getTestGroups(experimentId) (Array<TestGroup>)

We will return all Test Groups that are available for this experiment.

Example
console.log(window.igData?.user.getTestGroup("8bce9d31-cd20-4f4a-a070-a6970c7e9803"))

[{
    id: "8cead46f-a9d1-41dd-a864-86fc718ee133", 
    name: "Control Group",
    percentage: 50,
    isControl: true,
    freeShippingThreshold: 150,     // number | undefined
    shippingRate:                   // number | undefined
},
{
    id: "c2fdce4d-c3e2-4cf0-92aa-d3498ee67cc9", 
    name: "Test Group 1",
    percentage: 50,
    isControl: false,
    freeShippingThreshold: 150,     // number | undefined
    shippingRate:                   // number | undefined
}]

Get Test Group by Experiment ID

window.igData?.user.getTestGroup(experimentId) (TestGroup | null)

We will return a Test Group object based on the user's assignment for a given experiment. If the experiment is not live or the user has no assignment, we will return null.

Example
console.log(window.igData?.user.getTestGroup("8bce9d31-cd20-4f4a-a070-a6970c7e9803"))

{
    id: "8cead46f-a9d1-41dd-a864-86fc718ee133", 
    name: "Control Group",
    percentage: 50,
    isControl: true,
    freeShippingThreshold: 150,     // number | undefined
    shippingRate:                   // number | undefined
}

Assign User to Test Group

window.igData?.user.assignTestGroup(experimentId, testGroupId)

We will assign the user to the Test Group provided. This explicit assignment will take precedence over Audience Targeting, Page Targeting, or any other exclusions.

Example
window.igData?.user.assignTestGroup("8bce9d31-cd20-4f4a-a070-a6970c7e9803", 
"c2fdce4d-c3e2-4cf0-92aa-d3498ee67cc9"))

Last updated