Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


ReturnP: this is the info page that the respondent lands once returned from the shelf, all data captured and appended into the hidden variables must be on a same page so you can recode it from the API

...

Code Block
if (!IsInRdgMode()) {

    var link = encodeURIComponent(GetRespondentUrl('LandingLabel'));

    Redirect("https://survey.rose.conceptsauce.io?param_id=XXXXXXX&respondent_id=" + CurrentID() + "&link=" + link, true);

}

...

Code Block
languagejs
//get SUMMARY -----------------------------------------------------
var surveyIdCallObj = {
    event_type: "survey_data_request",
    action: "get_shop_shelf_summary_purchases",
    data: {
        target: {
            survey_id: survey_id,
            respondent_id: respondent_id,
            block_id: "shelf",
        },
    },
};
var surveyIdCallStr = JSON.stringify(surveyIdCallObj);

var resultAPIcall1 = $.parseJSON(
    $.ajax({
        url: "https://public-survey-data-api.rose.conceptsauce.io/api",
        type: "POST",
        data: surveyIdCallStr,
        dataType: "json",
        async: false,
        success: function (result) {
            console.log("success api call SUMMARY");
            console.log(result);
        },
        error: function (error) {
            console.log(error);
        },
    }).responseText
);



//Get all SKUs and append them into the variable
var P1summarySku = Confirmit.page.getQuestion("P1SKUs");
P1summarySku.setValue(null);

var P1SKU = resultAPIcall1.data.basket_summary.sku_list;


P1summarySku.setValue(P1SKU);

...

STEP 2.3

Get the shelf details and append them into the hidden variables

Code Block
languagejs
var reqBodyDetails = {
    event_type: "survey_data_request",
    action: "get_shop_shelf_detail_purchases",
    data: {
        target: {
            survey_id: survey_id,
            respondent_id: respondent_id,
            block_id: "shelf",
        },
    },
};

var reqBodyDetailsStr = JSON.stringify(reqBodyDetails);

var resultAPIcall2 = $.parseJSON(
    $.ajax({
        url: "https://public-survey-data-api.rose.conceptsauce.io/api",
        type: "POST",
        data: reqBodyDetailsStr,
        dataType: "json",
        async: false,
        success: function (result) {
            console.log("success api call DETAILS");
            console.log(result);
        },
        error: function (error) {
            console.log(error);
        },
    }).responseText
);

var rawPurchaseDet = resultAPIcall2.data.basket_details.raw_purchase_details;

//Get quantity for each SKU
var SkuQuant = [];

for (var z = 0; z < rawPurchaseDet.length; z++) {
    SkuQuant.push(rawPurchaseDet[z].quantity);
}
var SkuQtity = Confirmit.page.getQuestion("P1Quant");
SkuQtity.setValue(null);
SkuQtity.setValue(SkuQuant);


//Set total time spent at the shelf
var P1shelfTime = Confirmit.page.getQuestion("P1ShelfTime");
P1shelfTime.setValue(null);
P1exDur = resultAPIcall2.data.exercise_duration;
P1shelfTime.setValue(P1exDur);

...

STEP 2.4

Get the shelf details and append them into the hidden variables

Code Block
//get summary ITEMS looked at
var reqSumItems = {
    event_type: "survey_data_request",
    action: "get_shop_shelf_summary_items_looked_at",
    data: {
        target: {
            survey_id: survey_id,
            respondent_id: respondent_id,
            block_id: "shelf",
        },
    },
};

var reqSumItemsStr = JSON.stringify(reqSumItems);

var resultAPIcall3 = $.parseJSON(
    $.ajax({
        url: "https://public-survey-data-api.rose.conceptsauce.io/api",
        type: "POST",
        data: reqSumItemsStr,
        dataType: "json",
        async: false,
        success: function (result) {
            console.log("success api call Summary Items");
            console.log(result);
        },
        error: function (error) {
            console.log(error);
        },
    }).responseText
);


//recode all items looked at(bought and not bought, abe vsi4ki)
var itemsLookedAt = resultAPIcall3.data.items_looked_at;

var P1look = Confirmit.page.getQuestion("P1looked");
P1look.setValue(null);

var P1lookArr = [];

for (var p = 0; p < itemsLookedAt.length; p++) {
    P1lookArr.push(itemsLookedAt[p].sku);
}

P1look.setValue(P1lookArr);

...

STEP 2.5

Get all the items the respondent have looked at

Code Block
languagejs
 var greyoutObj = {
                    "shelf": {
                      "set:disabled_products": [
                      ]
                    }
                  }
 
  var chosen = "^f('SKU')[f('P2').get()].label()^";
  
    greyoutObj.shelf["set:disabled_products"].push(chosen);
     
  var chosenParam = JSON.stringify(greyoutObj);
  var end = btoa(chosenParam);

var linkquestion = Confirmit.page.getQuestion("linkDisabled");
linkquestion.setValue(end);

...

STEP 2.5.1

Pass the selection in the redirect link

...