Guide
Analytics Tracking
Category Events
2 min
{ "tab" "examples", "url" "https //{{ analytics url }}/analytics/categoryproductviewtracking", "name" "reporting category page views", "method" "get", "request" { "pathparameters" \[], "queryparameters" \[ { "kind" "required", "name" "klevu apikey", "type" "string", "description" "this is your klevu js api key " }, { "kind" "required", "name" "klevu categoryname", "type" "string", "description" "this is the name of the category being visited for example, stackable rings the name should not include parent categories " }, { "kind" "required", "name" "klevu categorypath", "type" "string", "description" "this is the complete hierarchy of the category being visited for example, jewellery;rings;stackable rings please note the use of a semicolon as the separator between a parent and a child category " }, { "kind" "required", "name" "klevu productids", "type" "string", "description" "comma separated list of product ids being shown on the current page of the category page for example, p1,p2,p3,p4,p5…\nall the product ids listed here are treated as impressions for these products " }, { "kind" "optional", "name" "klevu pagestartsfrom", "type" "string", "description" "offset of the first product being shown on this page for example, if you are displaying 30 products per page and if a customer is on the 2nd page, the value here should be 30 if on the 3rd page, it will be 60 " }, { "kind" "required", "name" "klevu shopperip", "type" "string", "description" "ip address of the shopper who viewed the category page \n\n if calling from javascript, this is an optional parameter " }, { "kind" "optional", "name" "klevu activefilters", "type" "string", "children" \[], "description" "this refers to the filters that were applied during the category page view event the format for the applied filters is \\"\<filterkey1> \<filtervalue1>;;\<filterkey2> \<filtervalue2>\\" multiple filters are separated by \\";;\\" for example, \\"style\ underseat luggage;;color\ blue\\" " }, { "kind" "optional", "name" "klevu abtestid", "type" "string", "children" \[], "description" "the unique identifier of the a/b test " }, { "kind" "optional", "name" "klevu abtestvariantid", "type" "string", "children" \[], "description" "the unique identifier of the a/b test variant " }, { "name" "klevu shopperip v4", "kind" "optional", "type" "string", "description" "ipv4 address of the shopper who viewed a category page ", "children" \[] }, { "name" "klevu shopperip v6", "kind" "optional", "type" "string", "description" "ipv6 address of the shopper who viewed a category page ", "children" \[] }, { "name" "data protection", "kind" "optional", "type" "boolean", "description" "if set to false, klevu's backend do not obtain the shoppers' ip address the default value is true ", "children" \[] }, { "name" "klevu uuid", "kind" "optional", "type" "string", "description" "universally unique identifier generated by klevu, it can be also considered as session id please obtain uuid using end point https //docs klevu com/apis/uuid", "children" \[] }, { "name" "klevu country", "kind" "optional", "type" "string", "description" "2 digit country code of the shopper who viewed a category valid codes can be found at https //developers google com/hotels/hotel prices/dev guide/country codes", "children" \[] }, { "name" "klevu city", "kind" "optional", "type" "string", "description" "city name of the shopper who viewed a category ", "children" \[] } ], "headerparameters" \[], "bodydataparameters" \[], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "ddxomvwnislr jx48ghqd", "code" "\<data>\n \<response>success\</response>\n\</data>", "language" "200", "customlabel" "" } ], "selectedlanguageid" "ddxomvwnislr jx48ghqd" }, "examples" { "languages" \[ { "id" "mmcwmnqghyefjv4j56p1h", "code" "\<?php\n\n$curl = curl init();\n\ncurl setopt array($curl, array(\n curlopt url => 'https //stats ksearchnet com/analytics/categoryproductviewtracking?klevu apikey=klevu 1234567890\&klevu categoryname=tees\&klevu categorypath=mens%253bshoes%2520and%2520trainers%253bsneakers\&klevu productids=31366450446398,31366450380862,31366479020094,31366447038526,31366447923262,31366448382014\&klevu pagestartsfrom=0',\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 => 'get',\n));\n\n$response = curl exec($curl);\n\ncurl close($curl);\necho $response;\n", "language" "php", "customlabel" "" }, { "id" "bbzdfxkvvz09pieodzhwc", "code" "// warning for get requests, body is set to null by browsers \n\nvar xhr = new xmlhttprequest();\nxhr withcredentials = true;\n\nxhr addeventlistener(\\"readystatechange\\", function() {\n if(this readystate === 4) {\n console log(this responsetext);\n }\n});\n\nxhr open(\\"get\\", \\"https //stats ksearchnet com/analytics/categoryproductviewtracking?klevu apikey=klevu 1234567890\&klevu categoryname=tees\&klevu categorypath=mens%253bshoes%2520and%2520trainers%253bsneakers\&klevu productids=31366450446398%2c31366450380862%2c31366479020094%2c31366447038526%2c31366447923262%2c31366448382014\&klevu pagestartsfrom=0\\");\n\nxhr send();", "language" "javascript", "customlabel" "" }, { "id" "3ikkepqx ffnmiw40czkp", "code" "okhttpclient client = new okhttpclient() newbuilder()\n build();\nrequest request = new request builder()\n url(\\"https //stats ksearchnet com/analytics/categoryproductviewtracking?klevu apikey=klevu 1234567890\&klevu categoryname=tees\&klevu categorypath=mens%3bshoes%20and%20trainers%3bsneakers\&klevu productids=31366450446398,31366450380862,31366479020094,31366447038526,31366447923262,31366448382014\&klevu pagestartsfrom=0\\")\n method(\\"get\\", null)\n build();\nresponse response = client newcall(request) execute();", "language" "java", "customlabel" "" }, { "id" "c6uome2hcxhngzofpqfkd", "code" "var request = require('request');\nvar options = {\n 'method' 'get',\n 'url' 'https //stats ksearchnet com/analytics/categoryproductviewtracking?klevu apikey=klevu 1234567890\&klevu categoryname=tees\&klevu categorypath=mens%3bshoes%20and%20trainers%3bsneakers\&klevu productids=31366450446398,31366450380862,31366479020094,31366447038526,31366447923262,31366448382014\&klevu pagestartsfrom=0',\n 'headers' {\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" "bbzdfxkvvz09pieodzhwc" }, "description" "use this api endpoint to submit category page views activity \n1 when the category response is received\n2 and also when a facet is clicked (triggering a follow up query) \n\n", "currentnewparameter" { "label" "query parameter", "value" "queryparameters" } } { "tab" "examples", "url" "https //{{ analytics url }}/analytics/categoryproductclicktracking", "name" "reporting category product clicks", "method" "get", "request" { "pathparameters" \[], "queryparameters" \[ { "kind" "required", "name" "klevu apikey", "type" "string", "description" "this is your klevu js api key " }, { "kind" "required", "name" "klevu categoryname", "type" "string", "description" "this is the name of the category being visited for example, stackable rings the name should not include parent categories " }, { "kind" "required", "name" "klevu categorypath", "type" "string", "description" "this is the complete hierarchy of the category being visited for example, jewellery;rings;stackable rings please note the use of a semicolon as the separator between a parent and a child category " }, { "kind" "required", "name" "klevu productid", "type" "string", "description" "this is the klevu id of the clicked product eg 54321 12345 " }, { "kind" "required", "name" "klevu productgroupid", "type" "string", "description" "this is the parent id of the clicked product eg 54321 for compound products with a parent and multiple child/variant products, this is the common id which ties the products together for simple products, please specify the same as klevu productid " }, { "kind" "required", "name" "klevu productvariantid", "type" "string", "description" "this is the child/variant id of the clicked product eg 12345 for compound products with a parent and multiple child/variant products, this is the id of the specific variant for simple products, please specify the same as klevu productid " }, { "kind" "optional", "name" "klevu productname", "type" "string", "description" "name of the product that was clicked " }, { "kind" "optional", "name" "klevu producturl", "type" "string", "description" "url of the product that was clicked " }, { "kind" "optional", "name" "klevu productsku", "type" "string", "description" "sku code of the product that was clicked " }, { "kind" "optional", "name" "klevu saleprice", "type" "string", "description" "decimal sale price of the product that was clicked " }, { "kind" "optional", "name" "klevu productratings", "type" "number", "description" "a decimal rating value between 0 and 5 of the product that was clicked " }, { "kind" "optional", "name" "klevu productposition", "type" "integer", "description" "position of the product on the category page when it was clicked for example, the value would be 0 if it is the first product on the first page the value will be 30, if it is the first product on the 2nd page with 30 products being displayed per page " }, { "kind" "required", "name" "klevu shopperip", "type" "string", "description" "ip address of the shopper who clicked the product(s) \n\n if calling from javascript, this is an optional parameter " }, { "kind" "optional", "name" "klevu activefilters", "type" "string", "children" \[], "description" "this refers to the filters that were applied during the product clicked event the format for the applied filters is \\"\<filterkey1> \<filtervalue1>;;\<filterkey2> \<filtervalue2>\\" multiple filters are separated by \\";;\\" for example, \\"style\ underseat luggage;;color\ blue\\" " }, { "kind" "optional", "name" "klevu abtestid", "type" "string", "description" "the unique identifier of the a/b test " }, { "kind" "optional", "name" "klevu abtestvariantid", "type" "string", "description" "the unique identifier of the a/b test variant \n" }, { "name" "klevu shopperip v4", "kind" "optional", "type" "string", "description" "ipv4 address of the shopper who clicked a product ", "children" \[] }, { "name" "klevu shopperip v6", "kind" "optional", "type" "string", "description" "ipv6 address of the shopper who clicked a product ", "children" \[] }, { "name" "data protection", "kind" "optional", "type" "boolean", "description" "if set to false, klevu's backend do not obtain the shoppers' ip address the default value is true ", "children" \[] }, { "name" "klevu uuid", "kind" "optional", "type" "string", "description" "universally unique identifier generated by klevu, it can be also considered as session id please obtain uuid using end point https //docs klevu com/apis/uuid", "children" \[] }, { "name" "klevu country", "kind" "optional", "type" "string", "description" "2 digit country code of the shopper who searched a term valid codes can be found at https //developers google com/hotels/hotel prices/dev guide/country codes", "children" \[] }, { "name" "klevu city", "kind" "optional", "type" "string", "description" "city name of the shopper who clicked a product ", "children" \[] } ], "headerparameters" \[], "bodydataparameters" \[], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "ddxomvwnislr jx48ghqd", "code" "\<data>\n \<response>success\</response>\n\</data>", "language" "200", "customlabel" "" } ], "selectedlanguageid" "ddxomvwnislr jx48ghqd" }, "examples" { "languages" \[ { "id" "mmcwmnqghyefjv4j56p1h", "code" "\<?php\n\n$curl = curl init();\n\ncurl setopt array($curl, array(\n curlopt url => 'https //stats ksearchnet com/analytics/categoryproductclicktracking?klevu apikey=klevu 1234567890\&klevu categoryname=sneakers\&klevu categorypath=mens%253bshoes%2520and%2520trainers%253bsneakers\&klevu productid=54321 12345\&klevu productgroupid=54321\&klevu productvariantid=12345\&klevu productname=smart%2520trainers\&klevu producturl=https%253a%252f%252fyour website com%252fproduct url\&klevu productsku=abc 123\&klevu saleprice=123 45\&klevu productratings=3\&klevu productposition=7\&klevu abtestid=9c8bm3o1 osjgoqn9 9mbjudid\&klevu abtestvariantid=if92kdmc 98ckcj89 98cjcd9d',\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 => 'get',\n));\n\n$response = curl exec($curl);\n\ncurl close($curl);\necho $response;\n", "language" "php", "customlabel" "" }, { "id" "bbzdfxkvvz09pieodzhwc", "code" "\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(\\"get\\", 'https //stats ksearchnet com/analytics/categoryproductviewtracking?klevu apikey=klevu 1234567890\&klevu categoryname=tees\&klevu categorypath=mens%253bshoes%2520and%2520trainers%253bsneakers\&klevu productids=31366450446398,31366450380862,31366479020094,31366447038526,31366447923262,31366448382014\&klevu pagestartsfrom=0');\n\nxhr send();", "language" "javascript", "customlabel" "" }, { "id" "3ikkepqx ffnmiw40czkp", "code" "okhttpclient client = new okhttpclient() newbuilder()\n build();\nrequest request = new request builder()\n url(\\"https //stats ksearchnet com/analytics/categoryproductclicktracking?klevu apikey=klevu 1234567890\&klevu categoryname=sneakers\&klevu categorypath=mens%3bshoes%20and%20trainers%3bsneakers\&klevu productid=54321 12345\&klevu productgroupid=54321\&klevu productvariantid=12345\&klevu productname=smart%20trainers\&klevu producturl=https%3a%2f%2fyour website com%2fproduct url\&klevu productsku=abc 123\&klevu saleprice=123 45\&klevu productratings=3\&klevu productposition=7\&klevu abtestid=9c8bm3o1 osjgoqn9 9mbjudid\&klevu abtestvariantid=if92kdmc 98ckcj89 98cjcd9d\\")\n method(\\"get\\", null)\n build();\nresponse response = client newcall(request) execute();", "language" "java", "customlabel" "" }, { "id" "c6uome2hcxhngzofpqfkd", "code" "var request = require('request');\nvar options = {\n 'method' 'get',\n 'url' 'https //stats ksearchnet com/analytics/categoryproductclicktracking?klevu apikey=klevu 1234567890\&klevu categoryname=sneakers\&klevu categorypath=mens%3bshoes%20and%20trainers%3bsneakers\&klevu productid=54321 12345\&klevu productgroupid=54321\&klevu productvariantid=12345\&klevu productname=smart%20trainers\&klevu producturl=https%3a%2f%2fyour website com%2fproduct url\&klevu productsku=abc 123\&klevu saleprice=123 45\&klevu productratings=3\&klevu productposition=7\&klevu abtestid=9c8bm3o1 osjgoqn9 9mbjudid\&klevu abtestvariantid=if92kdmc 98ckcj89 98cjcd9d',\n 'headers' {\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" "bbzdfxkvvz09pieodzhwc" }, "description" "use this api endpoint to submit the product clicks from category page results \n", "currentnewparameter" { "label" "query parameter", "value" "queryparameters" } } { "tab" "examples", "url" "https //config cdn ksearchnet com/abtest/public/usage/{{ your klevu apikey }}/", "name" "reporting a/b test variant view", "method" "post", "request" { "pathparameters" \[], "queryparameters" \[ { "kind" "required", "name" "sourceid", "type" "string", "description" "the unique identifier of the element to which the a/b test id and variant are assigned to in this case, it will be a category name " }, { "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 " }, { "kind" "required", "name" "type", "type" "string", "description" "the type of element to which an a/b test will be assigned for now, will be “cat nav” " } ], "headerparameters" \[], "bodydataparameters" \[], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "ddxomvwnislr jx48ghqd", "code" "", "language" "200", "customlabel" "" } ], "selectedlanguageid" "ddxomvwnislr jx48ghqd" }, "examples" { "languages" \[ { "id" "nuesrs n5vrha1ab9gv6y", "code" "{\n \\"sourceid\\" \\"womens;jeans\\",\n \\"abtestid\\" \\"9c8bm3o1 osjgoqn9 9mbjudid\\",\n \\"abtestvariantid\\" \\"if92kdmc 98ckcj89 98cjcd9d\\", \n \\"type\\" \\"cat nav\\"\n}", "language" "json", "customlabel" "" }, { "id" "mmcwmnqghyefjv4j56p1h", "code" "\<?php\n\n$curl = curl init();\n\ncurl setopt array($curl, array(\n curlopt url => 'https //config cdn ksearchnet com/abtest/public/usage/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 curlopt postfields =>'{\n \\"sourceid\\" \\"womens;jeans\\",\n \\"abtestid\\" \\"9c8bm3o1 osjgoqn9 9mbjudid\\",\n \\"abtestvariantid\\" \\"if92kdmc 98ckcj89 98cjcd9d\\", \n \\"type\\" \\"cat nav\\"\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" "bbzdfxkvvz09pieodzhwc", "code" "var data = json stringify({\\"sourceid\\" \\"womens;jeans\\",\\"abtestid\\" \\"9c8bm3o1 osjgoqn9 9mbjudid\\",\\"abtestvariantid\\" \\"if92kdmc 98ckcj89 98cjcd9d\\",\\"type\\" \\"cat nav\\"});\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 //config cdn ksearchnet com/abtest/public/usage/klevu 158755634955912036/\\");\nxhr setrequestheader(\\"content type\\", \\"application/json\\");\n\nxhr send(data);", "language" "javascript", "customlabel" "" }, { "id" "3ikkepqx ffnmiw40czkp", "code" "okhttpclient client = new okhttpclient() newbuilder()\n build();\nmediatype mediatype = mediatype parse(\\"application/json\\");\nrequestbody body = requestbody create(mediatype, \\"{\\\n \\\\\\"sourceid\\\\\\" \\\\\\"womens;jeans\\\\\\",\\\n \\\\\\"abtestid\\\\\\" \\\\\\"9c8bm3o1 osjgoqn9 9mbjudid\\\\\\",\\\n \\\\\\"abtestvariantid\\\\\\" \\\\\\"if92kdmc 98ckcj89 98cjcd9d\\\\\\", \\\n \\\\\\"type\\\\\\" \\\\\\"cat nav\\\\\\"\\\n}\\");\nrequest request = new request builder()\n url(\\"https //config cdn ksearchnet com/abtest/public/usage/klevu 158755634955912036/\\")\n method(\\"post\\", body)\n addheader(\\"content type\\", \\"application/json\\")\n build();\nresponse response = client newcall(request) execute();", "language" "java", "customlabel" "" }, { "id" "c6uome2hcxhngzofpqfkd", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' 'https //config cdn ksearchnet com/abtest/public/usage/klevu 158755634955912036/',\n 'headers' {\n 'content type' 'application/json'\n },\n body json stringify({\\"sourceid\\" \\"womens;jeans\\",\\"abtestid\\" \\"9c8bm3o1 osjgoqn9 9mbjudid\\",\\"abtestvariantid\\" \\"if92kdmc 98ckcj89 98cjcd9d\\",\\"type\\" \\"cat nav\\"})\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" "bbzdfxkvvz09pieodzhwc" }, "description" "use this api endpoint to report which a/b test variant is viewed \n\n", "currentnewparameter" { "label" "query parameter", "value" "queryparameters" } }