Cross Selling

Cross selling

The cross selling section is a module to manage cross selling with Inbenta.

Getting started

The first thing to do is configure the cross selling in backstage, for this example we configure a cross selling with id = 1 and the attribute 'img'.

Once we have the cross selling configured in backstage we can call the method of the client to retrieve the cross selling.

In this example we use the SDK, no directly the client. If we use the client we need to generate a session to track the information. generateSession method.

// We should call a client method when sdk is ready.

When we have the cross sellings endpoint results, we will print them in the crossSelling div and add the click event to track click in each cross selling.

// HTML for cross selling
<div id="crossSelling"></div>
// Function to manage cross selling 
function manageCrossSelling(results){
  var crossSellings = document.getElementById("crossSelling");
  results.forEach(function(result) {
    // Create img
    var element = document.createElement("img");
    element.className = "cross-selling__";
    element.src = result.attributes.img;

    // Manage click
    element.onclick = function (e){
      var code = result.tracking.clickCode;
      sdk.client.track('click', {code: code});

    // Append to crossSelling div