External Management

To manage two or more instances of the Backstage without losing information about search clicks, you can send external clicks from one instance to another.

Typically, you would have one search input and results from different Backstage instances.

Example: This is how you show two results components linked to a single search box:

// Create the SDK for instance A, along with the results component and the search box.
var sdkA = InbentaSearchSDK.createFromDomainKey("domain_key_instance_a", "inbenta_key_instance_a");
var resultsA = sdkA.component('results', '#results-a');
resultsA.linkTo(sdkA.component('search-box', '#search-box'));

// Create the SDK for instance B, along with the results component.
var sdkB = InbentaSearchSDK.createFromDomainKey("domain_key_instance_b", "inbenta_key_instance_b");
var resultsB = sdkB.component('results', '#results-b');
// Link both search stores.
resultsA.searchStore.on('search', function (request) {
    resultsB.searchStore.query = request.query;
    resultsB.searchStore.page = request.page;
    resultsB.searchStore.perPage = request.perPage;
});

// Manage click in instance A to send external click to instance B
resultsA.on('click', function (content) {
    sdkB.client.track('external_click', {
        externalCode: content.tracking.externalCode,
        searchCode: resultsB.getSearchCode(),
    });
});

Important: You should configure an external type inside the main instance to track the external click. The external type should be the name of the external instance, written in uppercase (So in the example above, if the external instance is instance_b, the external type will be INSTANCE_B).