Javascript API

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.

Overview

The Intelligems JS API lives on the window object: window.igData.

There 3 main attributes attached to the igData object are:

  1. User Object (igData.user) - Used for retrieving user, test group, and experiment info.

  2. Price Object (igData.price) - Used for complicated or custom price testing integrations.

  3. Campaigns Object (igData.campaigns) - Used for customizing your onsite campaign experience

Load Timing

As soon as Intelligems is fully loaded on the site, we will set the igData object on the window. As soon as this happens, we will fire a window event: ig:ready

Here's an example of how you might perform an action when Intelligems is loaded:

window.addEventListener('ig:ready', () => {
 const experiments = window.igData?.user.getExperiments();
 if (experiments.length) console.log("I have live experiments");
})

Last updated