---
title: Search Events
slug: apis/search-events
docTags: 
createdAt: 2024-06-25T00:24:41.222Z
---



:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "https://{{ Analytics_URL }}/analytics/n-search/search",
  "name": "Reporting Product Searches",
  "method": "GET",
  "request": {
    "pathParameters": [],
    "queryParameters": [
      {
        "kind": "required",
        "name": "klevu_apiKey",
        "type": "string",
        "description": "This is your Klevu JS API Key."
      },
      {
        "kind": "required",
        "name": "klevu_term",
        "type": "string",
        "description": "This is the term being searched. For example: iphone 5s.\n\n*For tracking of a facet click, append the selected facet to the term.\ne.g  iphone 5s [[color:black]]"
      },
      {
        "kind": "required",
        "name": "klevu_totalResults",
        "type": "string",
        "description": "This is the total number of results returned for the searched term. It must be an integer (e.g. 5)"
      },
      {
        "kind": "required",
        "name": "klevu_typeOfQuery",
        "type": "string",
        "description": "When you receive a response for a search query, look at the value of the typeOfQuery element under the metaData section (e.g. WILDCARD_AND, FUZZY_AND). You need to pass this value to this parameter."
      },
      {
        "kind": "required",
        "name": "klevu_shopperIP",
        "type": "string",
        "description": "IP address of the shopper who searched a term. \n\n*If calling from javascript (i.e. an ajax call), this is an optional parameter."
      },
      {
        "name": "klevu_shopperIP_v4",
        "kind": "optional",
        "type": "string",
        "description": "IPv4 address of the shopper who searched a term. \n",
        "children": []
      },
      {
        "name": "klevu_shopperIP_v6",
        "kind": "optional",
        "type": "string",
        "description": "IPv6 address of the shopper who searched a term. ",
        "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 searched a term.",
        "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": "ewnRZCOKsK8s4PdjFvhyM",
        "code": "curl --location --request GET 'https://stats.ksearchnet.com/analytics/n-search/search?apiKey=klevu-1234567890&term=red%20shoes&klevu_totalResults=35&klevu_typeOfQuery=WILDCARD_AND'",
        "language": "curl",
        "customLabel": ""
      },
      {
        "id": "EQqDeUhwCKDCWovOoWPGC",
        "code": "var request = require('request');\nvar options = {\n  'method': 'GET',\n  'url': 'https://stats.ksearchnet.com/analytics/n-search/search?apiKey=klevu-1234567890&term=red%20shoes&klevu_totalResults=35&klevu_typeOfQuery=WILDCARD_AND',\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": ""
      },
      {
        "id": "8jgVxehuUIB8HJb3WWGYb",
        "code": "var requestOptions = {\n  method: 'GET',\n  redirect: 'follow'\n};\n\nfetch(\"https://stats.ksearchnet.com/analytics/n-search/search?klevu_apiKey=klevu-1234567890&klevu_term=red%20shoes&klevu_totalResults=35&klevu_typeOfQuery=WILDCARD_AND\", requestOptions)\n  .then(response => response.text())\n  .then(result => console.log(result))\n  .catch(error => console.log('error', error));",
        "language": "javascript",
        "customLabel": ""
      },
      {
        "id": "6DGdWEWXLComG0sNANahm",
        "code": "import requests\n\nurl = \"https://stats.ksearchnet.com/analytics/n-search/search?apiKey=klevu-1234567890&term=red%20shoes&klevu_totalResults=35&klevu_typeOfQuery=WILDCARD_AND\"\n\npayload={}\nheaders = {}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "language": "python",
        "customLabel": ""
      },
      {
        "id": "ZX8_wo0Tig8YCFpmpqeIo",
        "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://stats.ksearchnet.com/analytics/n-search/search?apiKey=klevu-1234567890&term=red%20shoes&klevu_totalResults=35&klevu_typeOfQuery=WILDCARD_AND\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\n\nresponse = https.request(request)\nputs response.read_body\n",
        "language": "ruby",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "8jgVxehuUIB8HJb3WWGYb"
  },
  "description": "Use this API endpoint to submit the search activities:\n1.  When the search response is received\n2. And also when a facet is clicked (triggering a follow up query)\n\n",
  "currentNewParameter": {
    "label": "Query Parameter",
    "value": "queryParameters"
  },
  "autoGeneratedAnchorSlug": "reporting-product-searches",
  "legacyHash": "Ipf54-3vQYQlnxuq6ZTx6"
}
```
:::



:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "https://{{ Analytics_URL }}/analytics/productTracking",
  "name": "Reporting Product Clicks From Search Results",
  "method": "GET",
  "request": {
    "pathParameters": [],
    "queryParameters": [
      {
        "kind": "required",
        "name": "klevu_apiKey",
        "type": "string",
        "description": "This is your Klevu JS API Key."
      },
      {
        "kind": "required",
        "name": "klevu_keywords",
        "type": "string",
        "description": "This is the term being searched. For example: iphone 5s.\n\n*For tracking of a facet click, append the selected facet to the term.\ne.g  iphone 5s [[color:black]]"
      },
      {
        "kind": "required",
        "name": "klevu_type",
        "type": "string",
        "description": "This is constant value. The value must be clicked."
      },
      {
        "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": "required",
        "name": "klevu_productName",
        "type": "string",
        "description": "This is the product name of the clicked product."
      },
      {
        "kind": "required",
        "name": "klevu_productUrl",
        "type": "string",
        "description": "This is the product URL of the clicked product."
      },
      {
        "kind": "required",
        "name": "klevu_shopperIP",
        "type": "string",
        "description": "IP address of the shopper who clicked on a product. \n\n*If calling from javascript (i.e. an ajax call), this is an optional parameter."
      },
      {
        "name": "klevu_shopperIP_v4",
        "kind": "optional",
        "type": "string",
        "description": "IPv4 address of the shopper who clicked a product.\n",
        "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": "ewnRZCOKsK8s4PdjFvhyM",
        "code": "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, array(\n  CURLOPT_URL => 'https://stats.ksearchnet.com/analytics/productTracking?klevu_apiKey=klevu-1234567890&klevu_keywords=red%2520shoes&klevu_type=clicked&klevu_productId=54321-12345&klevu_productGroupId=54321&klevu_productVariantId=12345&klevu_productName=Smart%2520Trainers&klevu_productUrl=https%253A%252F%252Fyour.website.com%252Fproduct-url',\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": "curl",
        "customLabel": ""
      },
      {
        "id": "EQqDeUhwCKDCWovOoWPGC",
        "code": "var request = require('request');\nvar options = {\n  'method': 'GET',\n  'url': 'https://stats.ksearchnet.com/analytics/productTracking?klevu_apiKey=klevu-1234567890&klevu_keywords=red%20shoes&klevu_type=clicked&klevu_productId=54321-12345&klevu_productGroupId=54321&klevu_productVariantId=12345&klevu_productName=Smart%20Trainers&klevu_productUrl=https%3A%2F%2Fyour.website.com%2Fproduct-url',\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": ""
      },
      {
        "id": "8jgVxehuUIB8HJb3WWGYb",
        "code": "var 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/productTracking?klevu_apiKey=klevu-1234567890&klevu_keywords=red%2520shoes&klevu_type=clicked&klevu_productId=54321-12345&klevu_productGroupId=54321&klevu_productVariantId=12345&klevu_productName=Smart%2520Trainers&klevu_productUrl=https%253A%252F%252Fyour.website.com%252Fproduct-url\");\n\nxhr.send();",
        "language": "javascript",
        "customLabel": ""
      },
      {
        "id": "6DGdWEWXLComG0sNANahm",
        "code": "import requests\n\nurl = \"https://stats.ksearchnet.com/analytics/productTracking?klevu_apiKey=klevu-1234567890&klevu_keywords=red%20shoes&klevu_type=clicked&klevu_productId=54321-12345&klevu_productGroupId=54321&klevu_productVariantId=12345&klevu_productName=Smart%20Trainers&klevu_productUrl=https%3A%2F%2Fyour.website.com%2Fproduct-url\"\n\npayload={}\nheaders = {}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "language": "python",
        "customLabel": ""
      },
      {
        "id": "ZX8_wo0Tig8YCFpmpqeIo",
        "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://stats.ksearchnet.com/analytics/productTracking?klevu_apiKey=klevu-1234567890&klevu_keywords=red%20shoes&klevu_type=clicked&klevu_productId=54321-12345&klevu_productGroupId=54321&klevu_productVariantId=12345&klevu_productName=Smart%20Trainers&klevu_productUrl=https%3A%2F%2Fyour.website.com%2Fproduct-url\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\n\nresponse = https.request(request)\nputs response.read_body\n",
        "language": "ruby",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "8jgVxehuUIB8HJb3WWGYb"
  },
  "description": "Use this API endpoint to submit the product clicks from search results.\n",
  "currentNewParameter": {
    "label": "Query Parameter",
    "value": "queryParameters"
  },
  "autoGeneratedAnchorSlug": "reporting-product-clicks-from-search-results",
  "legacyHash": "-2qMTxhJIQMvtMeZ8hbid"
}
```
:::

