Category Events
2 min
Reporting Category Page Views
Use this API endpoint to submit category page views activity:
1. When the category response is received
2. And also when a facet is clicked (triggering a follow up query)
GET
https://{{ Analytics_URL }}/analytics/categoryProductViewTracking
Query Parameters
- klevu_apiKeystringrequiredDescription
- klevu_categoryNamestringrequiredDescription
- klevu_categoryPathstringrequiredDescription
- klevu_productIdsstringrequiredDescription
- klevu_pageStartsFromstringDescription
- klevu_shopperIPstringrequiredDescription
- klevu_activeFiltersstringDescription
- klevu_abTestIdstringDescription
- klevu_abTestVariantIdstringDescription
- klevu_shopperIP_v4stringDescription
- klevu_shopperIP_v6stringDescription
- data_protectionBooleanDescription
- klevu_uuidstringDescription
- klevu_countrystringDescription
- klevu_citystringDescription
php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
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',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
javascript
// WARNING: For GET requests, body is set to null by browsers.
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.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");
xhr.send();java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.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")
.method("GET", null)
.build();
Response response = client.newCall(request).execute();nodejs
var request = require('request');
var options = {
'method': 'GET',
'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',
'headers': {
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
200
<data>
<response>SUCCESS</response>
</data>
Reporting Category Product Clicks
Use this API endpoint to submit the product clicks from category page results.
GET
https://{{ Analytics_URL }}/analytics/categoryProductClickTracking
Query Parameters
- klevu_apiKeystringrequiredDescription
- klevu_categoryNamestringrequiredDescription
- klevu_categoryPathstringrequiredDescription
- klevu_productIdstringrequiredDescription
- klevu_productGroupIdstringrequiredDescription
- klevu_productVariantIdstringrequiredDescription
- klevu_productNamestringDescription
- klevu_productUrlstringDescription
- klevu_productSkustringDescription
- klevu_salePricestringDescription
- klevu_productRatingsNumberDescription
- klevu_productPositionIntegerDescription
- klevu_shopperIPstringrequiredDescription
- klevu_activeFiltersstringDescription
- klevu_abTestIdstringDescription
- klevu_abTestVariantIdstringDescription
- klevu_shopperIP_v4stringDescription
- klevu_shopperIP_v6stringDescription
- data_protectionBooleanDescription
- klevu_uuidstringDescription
- klevu_countrystringDescription
- klevu_citystringDescription
php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
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',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
javascript
var xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.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');
xhr.send();java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.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")
.method("GET", null)
.build();
Response response = client.newCall(request).execute();nodejs
var request = require('request');
var options = {
'method': 'GET',
'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',
'headers': {
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
200
<data>
<response>SUCCESS</response>
</data>
Reporting A/B Test Variant View
Use this API endpoint to report which A/B test variant is viewed.
POST
https://config-cdn.ksearchnet.com/abtest/public/usage/{{ Your Klevu apiKey }}/
Query Parameters
- sourceIdstringrequiredDescription
- abTestIdstringrequiredDescription
- abTestVariantIdstringrequiredDescription
- typestringrequiredDescription
json
{
"sourceId": "womens;jeans",
"abTestId": "9c8bm3o1-osjgoqn9-9mbjudid",
"abTestVariantId": "if92kdmc-98ckcj89-98cjcd9d",
"type": "CAT_NAV"
}php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://config-cdn.ksearchnet.com/abtest/public/usage/klevu-158755634955912036/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"sourceId": "womens;jeans",
"abTestId": "9c8bm3o1-osjgoqn9-9mbjudid",
"abTestVariantId": "if92kdmc-98ckcj89-98cjcd9d",
"type": "CAT_NAV"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
javascript
var data = JSON.stringify({"sourceId":"womens;jeans","abTestId":"9c8bm3o1-osjgoqn9-9mbjudid","abTestVariantId":"if92kdmc-98ckcj89-98cjcd9d","type":"CAT_NAV"});
var xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://config-cdn.ksearchnet.com/abtest/public/usage/klevu-158755634955912036/");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"sourceId\": \"womens;jeans\",\n \"abTestId\": \"9c8bm3o1-osjgoqn9-9mbjudid\",\n \"abTestVariantId\": \"if92kdmc-98ckcj89-98cjcd9d\", \n \"type\": \"CAT_NAV\"\n}");
Request request = new Request.Builder()
.url("https://config-cdn.ksearchnet.com/abtest/public/usage/klevu-158755634955912036/")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();nodejs
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://config-cdn.ksearchnet.com/abtest/public/usage/klevu-158755634955912036/',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({"sourceId":"womens;jeans","abTestId":"9c8bm3o1-osjgoqn9-9mbjudid","abTestVariantId":"if92kdmc-98ckcj89-98cjcd9d","type":"CAT_NAV"})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
200