Developers
Search
K
Comment on page

JavaScript API Command Reference

JAVASCRIPT API REFERENCE

cart

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.

Description

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.

Usage

["cart", items]

Parameters

Parameter
Type
Description
items
object
An array of items with the following properties:
  • item (string): The parent item's identifier (e.g. item group id).
  • quantity (number): The quantity of this item added to the cart.
  • price (number): The item's price.
  • uniqueItemId(string): The item's unique identifier (e.g. SKU).

Example

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"]);

category

The category command allows you to track the category a visitor is currently browsing.

Description

It tracks the category currently being browsed. Should be issued on category pages.

Usage

["category", category]

Parameters

Parameter
Type
Description
category
string
The product category description (e.g. "skirts")

Example

JavaScript
kd.push(["category", "skirts"]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);

purchase

The purchase command allows tracking purchases in your web store.

Decription

Tracks a purchase event. This command should be issued on your web store checkout confirmation page.

Usage

["purchase", purchaseObject]

Parameters

Parameter
Type
Description
purchaseObject
object
The purchase description object:
  • orderId (string): The purchase unique identifier.
  • items (array of objects): The items purchased. Purchased item properties:
    • item (string): The parent item's identifier (e.g. item group id).
    • quantity (number): The quantity of the item purchased.
    • price (number): The item's price.
    • uniqueItemId(string): The item's unique identifier (e.g. SKU).

Example

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"]);

rate

The rate command is used to collect explicit user ratings on items.

Description

Reports the user's rating for an item. Issue this command on the item's rating confirmation page.

Usage

["rate", itemId, value]

Parameters

Parameter
Type
Description
itemId
string
The unique identifier of the item.
value
number
Rating value

Example

JavaScript
kd.push(["rate", "item-23", 4]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);

setCustomerId

Description

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.

Usage

["setCustomerId",customerId]

Parameters

Parameter
Type
Description
customerId
string
Your unique customer identifier

Example

JavaScript
kd.push(["setCustomerId", "1234ABC78"]);

submit

Description

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.

Usage

["submit"]

Parameters

No parameters.

Example

JavaScript
kd.push(["view", "4459"]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);

view

The view command allows tracking products that visitors view on your website.

Description

Tracks a product view. Issue this command on product pages.

Usage

["view", itemId]

Parameters

Parameter
Type
Description
itemId
string
The parent item's identifier (e.g. item group id).

Example

JavaScript
kd.push(["view", "4459"]);
// Add the "submit" command to send the data to LYNX.
kd.push(["submit"]);