STEP 1
Add the redirect link for concept sauce in a script tag.
The redirect should look like the below:
Redirect("https://survey.rose.conceptsauce.io?param_id=PRMS01G3H5QXCJ252E6FK650KEGB0Y&respondent_id=" + CurrentID() + "&link=" + link, true);
param_id:
is the unique shelf ID, concept sauce will provide you with unique param_id for each shelfrespondent_id:
is used to pass the unique ID for each respondent, must contain only numbers, no special symbolsCurrentID():
holds the unique ID in Confirmit system once the respondent enters the linklink:
this is a variable that holds the invite link for the survey, it is used to redirect the respondent back to the survey, see details below:
var link = encodeURIComponent(GetRespondentUrl('ReturnP'));
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
if (!IsInRdgMode()) { var link = encodeURIComponent(GetRespondentUrl('LandingLabel')); Redirect("https://survey.rose.conceptsauce.io?param_id=XXXXXXX&respondent_id=" + CurrentID() + "&link=" + link, true); }
STEP 2
API integration:
Inside the info page that the respondents returns write the javascript code in the Javascript tab.
You can find the information about each API Call at - Virtual Shelf
STEP 2.1
Get the survey ID from ParamID, Check if Api call was successful
//Get survey ID from Param ID ------------------------------------- var paramsCallObj = { event_type: "params_crud", action: "get_params", data: { params_id: cellParamID, }, }; var paramsCallStr = JSON.stringify(paramsCallObj); var surveyIDcall = $.parseJSON( $.ajax({ url: "https://better-params-api.rose.conceptsauce.io/api", type: "POST", data: paramsCallStr, dataType: "json", async: false, success: function (result) { console.log("success id call"); console.log(result); }, error: function (error) { console.log(error); }, }).responseText ); //check if API call was succesful var survey_id = ""; if (surveyIDcall.code == 200) { survey_id = surveyIDcall.data.params.survey_id; }
STEP 2.2
Get shelf summary purchases and append the data into the hidden variables
//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
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
//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
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
if (!IsInRdgMode()) { var link = encodeURIComponent(GetRespondentUrl('ReturnB')); var chosenParam = f('linkDisabled').get(); Redirect("https://survey.rose.conceptsauce.io?param_id=PRMS01G3H5T63290RQZY2KG8250G53&respondent_id=" + CurrentID() + "&custom_params=" + chosenParam + "&link=" + link, true); }