For ease of use, Intelligems adds an object to the global window scope when the page loads. It primarily acts as a read interface for configurations and session-specific A/B tests.
In this article:
API Details
The root level object is called igData. It should load immediately following the loading of your Intelligems JavaScript library.
Overview
window.igData
User
window.igData.user
The following functions are available in igData.user:
user.igId
Example
console.log(igData.user.igId);
"ig_71e855a9313945b63eb35e0abd5b63361d48"
igId: string
The user's Intelligems IgId id.
user.getExperiments()
Example
console.log(igData.user.getExperiments());
[
{
"id": "8bce9d31-cd20-4f4a-a070-a6970c7e9803",
"name": "Price Test",
"isPreview": true
}
]
experiments: {
id: string;
name: string;
isPreview: boolean
}[] | null;
List of experiments the user is in.
user.getTestGroup([experimentId])
Example
console.log(igData.user.getTestGroup("8bce9d31-cd20-4f4a-a070-a6970c7e9803"))
{
id: "8cead46f-a9d1-41dd-a864-86fc718ee133",
name: "Control Group",
percentage: 33,
isControl: true
}
experimentId: string
Returns
testGroup: {
id: string;
name: string;
percentage: number;
isControl: boolean;
} | null
The user's test group based on experiment ID
user.getTestGroupName([experimentId])
Example
igData.user.getTestGroupName("8bce9d31-cd20-4f4a-a070-a6970c7e9803")
"Control Group"
experimentId: string
testGroupName: string
User's test group name based on experiment ID.
Price
window.igData.price
The following functions are available in igData.price:
- getPriceByVariantId([variantId])
- getDiscountByVariantId([variantId])
- getAltProductHandle([handle])
- getAltVariantId([variantId])
price.getPriceByVariantId([variantId])
Example
console.log(igData.price.getPriceByVariantId(32305433935974));
"89.95"
variantId: string
price: string | null
The price for this product based on the user's test group and the product variant id.
If the variant is not included in any experiment, it will return null.
price.getDiscountByVariantId([variantId])
Example
console.log(igData.price.getDiscountByVariantId(32305433935974));
"1005"
variantId: string
discount: string | null
The discount for this user based on their test group and the product variant id. This discount is in cents (or equivalent currency).
price.getAltProductHandle([handle])
Example
console.log(igData.price.getAltProductHandle("dutch-oven"));
"dutch-oven-1"
handle: string
altHandle: string
Product handle of duplicated product based on the user's current test group.
price.getAltVariantId([variantId])
Example
console.log(igData.price.getAltVariantId("32305433935974"));
"51805463582052"
variantId: string
variantId: string | null
Corresponding variant ID of duplicated product based on the passed variant ID and the user's current test group.