Guide
Smart Category Merchandising
A/B Test
5 min
if you haven't gone through the prerequisites and the v2 structure, please have a look at overview docid\ czeodl0skcuv 18ipuplr klevu can also power your category pages using a/b testing this means that for a given test and variant combination, the products for a given category are retrieved using the visual merchandising rules configured for that a/b test and variant allocating variants to store categories klevu allocates for each category, an a/b test and a variant with their ids for category merchandising, the type will always be “cat nav” our recommendation is that this request be polled at an interval between 20 minutes and 1 hour, to get either new allocations or skewed allocations of variants to categories that were not yet clicked by a shop customer as long as an a/b test id is received as a response on this call, said a/b test is considered active once an id is no longer received in the response of this call, it should be removed from the local browser storage for each assignment, the distribution of variants can be different for the same a/b test id and categories if a category with an a/b test variant id is selected and viewed by a shop customer, that state of having been visited should be recorded, and once another variant id is received on the response for a visited category, it should be ignored if a variant id is received for a category that has not yet been visited by a shop customer, that variant id can be assigned to the category and it can overwrite any already existing values in the local browser storage tab examples url https api ksearchnet com abtest public allocation klevu 158755634955912036 name retrieve all possible a b test allocation variants method post request pathparameters queryparameters headerparameters bodydataparameters formdataparameters results languages id w1fwy9mowmwlhqkz jsr4 code n assigned n n sourceid womens;jeans n abtestid 101 n abtestvariantid aaa n type cat nav n n n sourceid womens;shirts n abtestid 101 n abtestvariantid bbb n type cat nav n n n sourceid mens;hoodies n abtestid 101 n abtestvariantid aaa n type cat nav n n n sourceid kids;toys n abtestid 202 n abtestvariantid xyz n type cat nav n n n language 200 customlabel selectedlanguageid w1fwy9mowmwlhqkz jsr4 examples languages id 1kkngprjw2qws1a3iujb2 code ?php n n curl curl init ; n ncurl setopt array curl array n curlopt url https api ksearchnet com abtest public allocation klevu 158755634955912036 n curlopt returntransfer true n curlopt encoding n curlopt maxredirs 10 n curlopt timeout 0 n curlopt followlocation true n curlopt http version curl http version 1 1 n curlopt customrequest post n ; n n response curl exec curl ; n ncurl close curl ; necho response; n language php customlabel id zl 4m 0p ibcbzkag vz6 code okhttpclient client new okhttpclient newbuilder n build ; nmediatype mediatype mediatype parse text plain ; nrequestbody body requestbody create mediatype ; nrequest request new request builder n url https api ksearchnet com abtest public allocation klevu 158755634955912036 n method post body n build ; nresponse response client newcall request execute ; language java customlabel id os3wyepfh rzvdo7tvjk0 code curl location request post https api ksearchnet com abtest public allocation klevu 158755634955912036 n header accept application json language curl customlabel id wdc7hoekum1bdpss0o32z code var request require request ; nvar options n method post n url https api ksearchnet com abtest public allocation klevu 158755634955912036 n headers n accept application json n n ; nrequest options function error response n if error throw new error error ; n console log response body ; n ; n language nodejs customlabel id 9tsghg6lfgrbwoaiufa4u code var myheaders new headers ; nmyheaders append accept application json ; n nvar requestoptions n method post n headers myheaders n redirect follow n ; n nfetch https api ksearchnet com abtest public allocation klevu 158755634955912036 requestoptions n then response response text n then result console log result n catch error console log error error ; language javascript customlabel selectedlanguageid 1kkngprjw2qws1a3iujb2 description the end point is used to reteriving available a b test variants currentnewparameter label body parameter value bodydataparameters category product search with a/b test tab request url https your apiv2 url cs v2 search name a b test using category merchandising method post request pathparameters queryparameters headerparameters bodydataparameters kind required name typeofrequest type string description this parameter defines the type of request it is which should be catnav for category merchandising queries there are other values available detailed elsewhere in the documentation kind required name categorypath type string description specify the name of the category to retrieve results from in the same case and format as it is indexed with klevu n nfor nested categories use the ; character to separate the hierarchy for example for mens shoes trainers and sneakers you would specify mens;shoes;trainers and sneakers kind required name abtestid type string description the unique identifier of the a b test kind required name abtestvariantid type string description the unique identifier of the a b test variant formdataparameters results languages id 3xlvmt855lgkjoht0npxg code n meta n qtime 16 n responsecode 200 n n queryresults n n id categoryproducts n meta n qtime 12 n noofresults 12 n totalresultsfound 73 n typeofsearch wildcard and n offset 0 n debugginginformation n notificationcode 1 n searchedterm n apikey klevu 156925593843210765 n ispersonalised false n n records n n discount n hidegroupprices n type hoodies sweatshirts n itemgroupid 4384033833022 n freeshipping n storebasecurrency gbp n price 75 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products wj01 red main c9193846 bc80 4537 b810 4f6ad82dd6fe medium jpg?v 1575478019 n currency gbp n instock yes n id 31366456541246 n imagehover n sku wj01 s red n brand ksd n startprice n image https cdn shopify com s files 1 0116 9457 1582 products wj01 red main c9193846 bc80 4537 b810 4f6ad82dd6fe medium jpg?v 1575478019 n deliveryinfo n hideaddtocart n saleprice 75 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets;;hoodies sweatshirts ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products stellar solar jacket s red n tags cold whether comfortable crewneck grayson hoodie machine sweatshirt winter wool n size small n name stellar solar jacket n shortdesc beat the heat and protect yourself from sunrays with the stellar solar jacket it s loaded with all the engineered features you need for an intense safe outdoor workout 100 uv protection a breathable perforated construction and advanced moist n category jackets;;hoodies sweatshirts n n n discount n hidegroupprices n type jackets n itemgroupid 4384052215870 n freeshipping n storebasecurrency gbp n price 99 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products mj08 blue main bb248254 73cc 4521 8105 fe2277267348 medium jpg?v 1575478286 n currency gbp n instock yes n id 31366487441470 n imagehover n sku mj08 xs blue n brand ksd n startprice n image https cdn shopify com s files 1 0116 9457 1582 products mj08 blue main bb248254 73cc 4521 8105 fe2277267348 medium jpg?v 1575478286 n deliveryinfo n hideaddtocart n saleprice 99 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products lando gym jacket blue n tags blue machine royal zipped n size small n name lando gym jacket n shortdesc the lando gym jacket offers strategic ventilation at perspiration prone areas while moisture wicking technology helps you stay dry side seam pockets house your favorite media device so you re plugged in when working out gray polyester n category jackets n n n discount n hidegroupprices n type jackets n itemgroupid 4384033341502 n freeshipping n storebasecurrency gbp n price 84 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products wj04 orange main 098af8fb 1cf2 473f 907a 10922e39beae medium jpg?v 1575478007 n currency gbp n instock yes n id 31366455590974 n imagehover n sku wj04 xs orange n brand mnh n startprice n image https cdn shopify com s files 1 0116 9457 1582 products wj04 orange main 098af8fb 1cf2 473f 907a 10922e39beae medium jpg?v 1575478007 n deliveryinfo n hideaddtocart n saleprice 84 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products ingrid running jacket orange n tags comfort machine royal running zipped n size small n name ingrid running jacket n shortdesc the ingrid running jacket combines sleek design and high performance with slim contoured fit and moisture wicking fabric it features a full zip construction and a collared neck to keep the elements out and body heat in slim fit moi n category jackets n n n discount n hidegroupprices n type jackets n itemgroupid 4384031244350 n freeshipping n storebasecurrency gbp n price 77 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products wj06 green main 30b7fa7f a3ce 4513 9307 822bf013a89d medium jpg?v 1575477963 n currency gbp n instock yes n id 31366453067838 n imagehover n sku wj06 xs green n brand ksd n startprice n image https cdn shopify com s files 1 0116 9457 1582 products wj06 green main 30b7fa7f a3ce 4513 9307 822bf013a89d medium jpg?v 1575477963 n deliveryinfo n hideaddtocart n saleprice 77 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products juno jacket green n tags adjustable comfort machine royal running zipped n size large n name juno jacket n shortdesc on colder than comfortable mornings you ll love warming up in the juno all ways performanc jacket designed to compete with wind and chill built in cocona technology aids evaporation while a special zip placket and stand up collar keep your ne n category jackets n n n discount n hidegroupprices n type jackets n itemgroupid 4384052084798 n freeshipping n storebasecurrency gbp n price 99 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products mj08 green main 7f692ff8 45b0 4d08 8371 a2044df82752 medium jpg?v 1575478284 n currency gbp n instock yes n id 31366487310398 n imagehover n sku mj08 xs green n brand mnh n startprice n image https cdn shopify com s files 1 0116 9457 1582 products mj08 green main 7f692ff8 45b0 4d08 8371 a2044df82752 medium jpg?v 1575478284 n deliveryinfo n hideaddtocart n saleprice 99 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products lando gym jacket green n tags green machine royal zipped n size medium n name lando gym jacket n shortdesc the lando gym jacket offers strategic ventilation at perspiration prone areas while moisture wicking technology helps you stay dry side seam pockets house your favorite media device so you re plugged in when working out gray polyester n category jackets n n n discount n hidegroupprices n type jackets n itemgroupid 4384051527742 n freeshipping n storebasecurrency gbp n price 66 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products mj10 red main 9e1898b9 9d4a 41df 8dc6 7d31cd23c34e medium jpg?v 1575478275 n currency gbp n instock yes n id 31366485966910 n imagehover n sku mj10 xs red n brand mnh n startprice n image https cdn shopify com s files 1 0116 9457 1582 products mj10 red main 9e1898b9 9d4a 41df 8dc6 7d31cd23c34e medium jpg?v 1575478275 n deliveryinfo n hideaddtocart n saleprice 66 0 n swatchesinfo n weight n klevu category klevu product;products;;tops;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products mars heattech trade pullover red n tags machine red royal zipped n size medium n name mars heattech pullover n shortdesc the mars heattech jacket defense against winter climes so you can play offense in the park on the trail or in the deck chair great for the ski lodge or stadium it features a wind and water resistant outer shell with a draw cord hood and deep n category tops;;jackets n n n discount n hidegroupprices n type jackets n itemgroupid 4384033603646 n freeshipping n storebasecurrency gbp n price 56 25 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products wj02 blue main 8549c057 4567 4b63 ac2e 2068d345ff28 medium jpg?v 1575478014 n currency gbp n instock yes n id 31366456279102 n imagehover n sku wj02 xs blue n brand ksd n startprice n image https cdn shopify com s files 1 0116 9457 1582 products wj02 blue main 8549c057 4567 4b63 ac2e 2068d345ff28 medium jpg?v 1575478014 n deliveryinfo n hideaddtocart n saleprice 56 25 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products josie yoga jacket blue n tags comfort machine royal running zipped n size small n name josie yoga jacket n shortdesc when your near future includes yoga the cozy comfort of the josie yoga jacket gets your mind and body ready stretchy cooltech fabric with zipper pockets makes this jacket the right gear for studio time or teatime after slate rouched n n category jackets n n n discount n hidegroupprices n type jackets n itemgroupid 4384052150334 n freeshipping n storebasecurrency gbp n price 99 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products mj08 gray main 3787cf65 8e0a 4540 8f11 6d188980a6eb medium jpg?v 1575478285 n currency gbp n instock yes n id 31366487375934 n imagehover n sku mj08 xs gray n brand kke n startprice n image https cdn shopify com s files 1 0116 9457 1582 products mj08 gray main 3787cf65 8e0a 4540 8f11 6d188980a6eb medium jpg?v 1575478285 n deliveryinfo n hideaddtocart n saleprice 99 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products lando gym jacket gray n tags gray machine royal zipped n size large n name lando gym jacket n shortdesc the lando gym jacket offers strategic ventilation at perspiration prone areas while moisture wicking technology helps you stay dry side seam pockets house your favorite media device so you re plugged in when working out gray polyester n category jackets n n n discount n hidegroupprices n type jackets n itemgroupid 4384033243198 n freeshipping n storebasecurrency gbp n price 84 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products wj04 white main d8fa2b03 08ff 485c afd1 b3761e70e9ce medium jpg?v 1575478004 n currency gbp n instock yes n id 31366455427134 n imagehover n sku wj04 xs white n brand kke n startprice n image https cdn shopify com s files 1 0116 9457 1582 products wj04 white main d8fa2b03 08ff 485c afd1 b3761e70e9ce medium jpg?v 1575478004 n deliveryinfo n hideaddtocart n saleprice 84 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products ingrid running jacket white n tags comfort machine royal running zipped n size medium n name ingrid running jacket n shortdesc the ingrid running jacket combines sleek design and high performance with slim contoured fit and moisture wicking fabric it features a full zip construction and a collared neck to keep the elements out and body heat in slim fit moi n category jackets n n n discount n hidegroupprices n type jackets n itemgroupid 4384033308734 n freeshipping n storebasecurrency gbp n price 84 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products wj04 red main 5c76d8d8 ad1a 414f b6b7 9edccc50b955 medium jpg?v 1575478005 n currency gbp n instock yes n id 31366455525438 n imagehover n sku wj04 xs red n brand ksd n startprice n image https cdn shopify com s files 1 0116 9457 1582 products wj04 red main 5c76d8d8 ad1a 414f b6b7 9edccc50b955 medium jpg?v 1575478005 n deliveryinfo n hideaddtocart n saleprice 84 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products ingrid running jacket red n tags comfort machine royal running zipped n size large n name ingrid running jacket n shortdesc the ingrid running jacket combines sleek design and high performance with slim contoured fit and moisture wicking fabric it features a full zip construction and a collared neck to keep the elements out and body heat in slim fit moi n category jackets n n n discount n hidegroupprices n type hoodies sweatshirts n itemgroupid 4384033964094 n freeshipping n storebasecurrency gbp n price 75 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products wj01 blue main d6ed0a23 7d18 42d4 921c 5669f65a7580 medium jpg?v 1575478022 n currency gbp n instock yes n id 31366456672318 n imagehover n sku wj01 s blue n brand mnh n startprice n image https cdn shopify com s files 1 0116 9457 1582 products wj01 blue main d6ed0a23 7d18 42d4 921c 5669f65a7580 medium jpg?v 1575478022 n deliveryinfo n hideaddtocart n saleprice 75 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets;;hoodies sweatshirts ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products stellar solar jacket s blue n tags cold whether comfortable crewneck grayson hoodie machine sweatshirt winter wool n size small n name stellar solar jacket n shortdesc beat the heat and protect yourself from sunrays with the stellar solar jacket it s loaded with all the engineered features you need for an intense safe outdoor workout 100 uv protection a breathable perforated construction and advanced moist n category jackets;;hoodies sweatshirts n n n discount n hidegroupprices n type jackets n itemgroupid 4384052412478 n freeshipping n storebasecurrency gbp n price 72 00 n toprice n imageurl https cdn shopify com s files 1 0116 9457 1582 products mj07 red main 7fb57683 fddb 44a9 90aa fc03536bbd90 medium jpg?v 1575478289 n currency gbp n instock yes n id 31366487769150 n imagehover n sku mj07 xs red n brand kke n startprice n image https cdn shopify com s files 1 0116 9457 1582 products mj07 red main 7fb57683 fddb 44a9 90aa fc03536bbd90 medium jpg?v 1575478289 n deliveryinfo n hideaddtocart n saleprice 72 0 n swatchesinfo n weight n klevu category klevu product;products;;jackets ku kucategory ku n totalvariants 0 n groupprices n url https jsv2 shopify demo ksearchmisc com products orion two tone fitted jacket red n tags machine red royal zipped n size large n name orion two tone fitted jacket n shortdesc while you re getting fit you need a fitted jacket to match striking color blocking patterns on hood shoulders and arms are hallmarks of the orion two tone fitted jacket they provide eye catching contrast against the rich torso tones of this 1 n category jackets n n n filters n n n language 200 customlabel selectedlanguageid 3xlvmt855lgkjoht0npxg examples languages id jsu7dlyyj euh63ysp682 code n recordqueries n n id categoryproducts n typeofrequest catnav n settings n query n categorypath jackets n n abtestid 9c8bm3o1 osjgoqn9 9mbjudid n abtestvariantid if92kdmc 98ckcj89 98cjcd9d n n n n context n apikeys n klevu 156925593843210765 n n n language json customlabel request body json id 8yg33te4jzfowp5yebmjh code ?php n n curl curl init ; n ncurl setopt array curl array n curlopt url https eucs15v2 ksearchnet com cs v2 search n curlopt returntransfer true n curlopt encoding n curlopt maxredirs 10 n curlopt timeout 0 n curlopt followlocation true n curlopt http version curl http version 1 1 n curlopt customrequest post n curlopt postfields n recordqueries n n id categoryproducts n typeofrequest catnav n settings n query n categorypath jackets n n abtestid 9c8bm3o1 osjgoqn9 9mbjudid n abtestvariantid if92kdmc 98ckcj89 98cjcd9d n n n n context n apikeys n klevu 156925593843210765 n n n n curlopt httpheader array n content type application json n n ; n n response curl exec curl ; n ncurl close curl ; necho response; n language php customlabel id wcdgtssqaxfiwklk2v174 code var data json stringify recordqueries id categoryproducts typeofrequest catnav settings query categorypath jackets abtestid 9c8bm3o1 osjgoqn9 9mbjudid abtestvariantid if92kdmc 98ckcj89 98cjcd9d context apikeys klevu 156925593843210765 ; n nvar xhr new xmlhttprequest ; nxhr withcredentials false; n nxhr addeventlistener readystatechange function n if this readystate 4 n console log this responsetext ; n n ; n nxhr open post https eucs15v2 ksearchnet com cs v2 search ; nxhr setrequestheader content type application json ; n nxhr send data ; language javascript customlabel id npw0nije j5r9i5w4bgn0 code okhttpclient client new okhttpclient newbuilder n build ; nmediatype mediatype mediatype parse application json ; nrequestbody body requestbody create mediatype n recordqueries n n id categoryproducts n typeofrequest catnav n settings n query n categorypath jackets n n abtestid 9c8bm3o1 osjgoqn9 9mbjudid n abtestvariantid if92kdmc 98ckcj89 98cjcd9d n n n n context n apikeys n klevu 156925593843210765 n n n ; nrequest request new request builder n url https eucs15v2 ksearchnet com cs v2 search n method post body n addheader content type application json n build ; nresponse response client newcall request execute ; language java customlabel id 0ih7niekhhfml7cry51j code var request require request ; nvar options n method post n url https eucs15v2 ksearchnet com cs v2 search n headers n content type application json n n body json stringify recordqueries id categoryproducts typeofrequest catnav settings query categorypath jackets abtestid 9c8bm3o1 osjgoqn9 9mbjudid abtestvariantid if92kdmc 98ckcj89 98cjcd9d context apikeys klevu 156925593843210765 n n ; nrequest options function error response n if error throw new error error ; n console log response body ; n ; n language nodejs customlabel selectedlanguageid jsu7dlyyj euh63ysp682 description this is an example how to fetch products from specific a b test variant n nnote your apiv2 url can be found in your kmc under store settings currentnewparameter label body parameter value bodydataparameters try it here!