Comment on page
JavaScript API Command Reference
JAVASCRIPT API REFERENCE
With the
cart
command you can track the status of your visitor's cart, sending to LYNX the items your visitors have added to their cart.This command tracks the items currently in the visitor’s shopping cart. It should be issued on the cart page and every time the customer adds/removes an item to/from the cart.
["cart", items]
Parameter | Type | Description |
items | object | An array of items with the following properties:
|
JavaScript
kd.push(["cart", [
{"item": "4459", "price": 15, "quantity": 1, "uniqueItemId":"4459010"},
{"item": "5960", "price": 35, "quantity": 4, "uniqueItemId":"5960012"}
]
]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);
The
category
command allows you to track the category a visitor is currently browsing.It tracks the category currently being browsed. Should be issued on category pages.
["category", category]
Parameter | Type | Description |
category | string | The product category description (e.g. "skirts") |
JavaScript
kd.push(["category", "skirts"]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);
The
purchase
command allows tracking purchases in your web store. Tracks a purchase event. This command should be issued on your web store checkout confirmation page.
["purchase", purchaseObject]
Parameter | Type | Description |
purchaseObject | object | The purchase description object:
|
JavaScript
kd.push(["purchase", {
"orderId": "786222",
"items": [
{"item": "4459", "price": 99.9, "quantity": 1, "uniqueItemId":"4459010"},
{"item": "5960", "price": 39.7, "quantity": 4, "uniqueItemId":"5960012"}
]
}]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);
The
rate
command is used to collect explicit user ratings on items.Reports the user's rating for an item. Issue this command on the item's rating confirmation page.
["rate", itemId, value]
Parameter | Type | Description |
itemId | string | The unique identifier of the item. |
value | number | Rating value |
JavaScript
kd.push(["rate", "item-23", 4]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);
Sets your customer identifier for known visitors. Issue this command when you are able to identify the current visitor (e.g. After login). This command is different from all the other commands in that it is executed immediately after being pushed to the command queue. It doesn't send any data to the server since it sets the customer identifier in the browser's cookie, and therefore, the
submit
command is not required for its execution.["setCustomerId",customerId]
Parameter | Type | Description |
customerId | string | Your unique customer identifier |
JavaScript
kd.push(["setCustomerId", "1234ABC78"]);
Triggers the execution of the commands stored in the command queue.
submit
should be issued on the website pages where you want to execute the commands previously added to the queue.["submit"]
No parameters.
JavaScript
kd.push(["view", "4459"]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);
The
view
command allows tracking products that visitors view on your website. Tracks a product view. Issue this command on product pages.
["view", itemId]
Parameter | Type | Description |
---|---|---|
itemId | string | The parent item's identifier (e.g. item group id). |
JavaScript
kd.push(["view", "4459"]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);