Event Listening and Control Group Check for Eureka SDK

Prev Next

For an SDK campaign, Insider One loads no content (HTML/CSS); only the eureka:sdk:campaign:ready event is fired. You need to draw your listing pages using SDK fetch methods for variations.

To decide if the user is in the variation or control group, you need to user control group methods explained below:

Control Group Check

The control group is the group of people to whom Insider One does not show any campaign. It’s the base group for A/B, where users see the default UI and data.

To choose the data source when drawing the listing page or pop-up (for A/B testing):

  • Control group: Eureka requires you to use your own data source.

  • Variation: Eureka requires you to use Insider data via SDK fetch methods.

Method:

Insider.eureka.isOnControlGroup(campId); //with the builderId of the campaign
Insider.campaign.isControlGroup(variationId); //with the variationId of the campaign

Parameter: campId/variationId (from event payload or config).

Returns:

  • true → user is in the control group;

  • false → user is in a variation.

Event Listening Example

Eureka requires you to listen for the campaign-ready moment as follows:

Insider.eventManager.once('eureka:sdk:campaign:ready', function (event, data) {
    const variationId = data.id;
    const isOnControlGroup = Insider.eureka.isOnControlGroup(campId);

    if (!isOnControlGroup) {
        // Variation: fetch product data via SDK and draw the page
        Insider.eureka.fetch.search(campId, 'queryA', {}).then(function (response) {
            response.items.forEach(function (item) {
              //draw page with data
            });
        });
    } else {
      //Control group: you draw the page with your own data source
    }

    // Log: page view (both control and variation)
    Insider.eureka.track.search(campId, 'queryA', { /* payload */ });
});

Alternatively, check the control group first and then listen for the event:

const campId = 123; // From panel
const isOnControlGroup = Insider.eureka.isOnControlGroup(campId);

if (isOnControlGroup) {
    //Control group: you draw the page with your own data source
} else {
    // Variation: fetch product data via SDK and draw the page
    Insider.eventManager.once('eureka:sdk:campaign:ready', function (event, data) {        
        Insider.eureka.fetch.search(campId, 'queryA', {}).then(function (response) {
            response.items.forEach(function (item) {
              //draw page with data
            });
        });
    });
}

// Log: page view (both control and variation)
Insider.eureka.track.search(campId, 'queryA', { /* payload */ });