Developers
Search…
JavaScript API Command Reference
JAVASCRIPT API REFERENCE

cart

With the cart command, you can send to LYNX the products your visitors have added to their cart.

Description

Reports the list of items in the visitor’s shopping cart.

Placement

Issue this command on the cart page.
You must reissue the cart and submit commands each time the customer adds/removes an item to/from the cart.

Usage

1
["cart", descriptor]
Copied!

Parameters

Parameter
Type
Description
descriptor
object
The description of the cart with the following properties:
    An array of items. Each item added to the cart has the following properties:
      item (string): The item's identifier.
      quantity (number): The quantity of this item added to the cart.
      price (number): The item's price.
      uniqueItemId(string): The item's unique identifier.

Example

JavaScript
HTML
1
kd.push(["cart", [
2
{"item": "4459", "price": 15, "quantity": 1, "uniqueItemId":"4459010"},
3
{"item": "5960", "price": 35, "quantity": 4, "uniqueItemId":"5960012"}
4
]
5
]);
6
7
// Send the data to LYNX.
8
// Should be the last call on the page, called only once.
9
kd.push(["submit"]);
Copied!
1
<script>
2
var kd = kd || [];
3
(function() {
4
var scriptId = 'kd-js-api';
5
if (document.getElementById(scriptId)) return;
6
var js = document.createElement('script'); js.id = scriptId;
7
js.setAttribute('merchantId', 'YOUR-MERCHANT-ID');
8
js.setAttribute('async', true);
9
js.src = 'https://cdn.kickdynamic.com/kd-lynx-v1.js';
10
var scriptTag = document.getElementsByTagName('script')[0];
11
scriptTag.parentNode.insertBefore(js, scriptTag);
12
})();
13
</script>
Copied!

category

The category command, allows you to track the category that's currently being browsed by your visitor.

Description

Tracks the category currently being browsed.

Placement

Issue this command only on category pages.

Usage

1
['category', category]
Copied!

Parameters

Parameter
Type
Description
category
string
The product category description

Example

JavaScript
HTML
1
kd.push(["category", "skirts"]);
2
// Send the data to LYNX.
3
// Should be the last call on the page, called only once.
4
kd.push(["submit"]);
Copied!
1
<script>
2
var kd = kd || [];
3
(function() {
4
var scriptId = 'kd-js-api';
5
if (document.getElementById(scriptId)) return;
6
var js = document.createElement('script'); js.id = scriptId;
7
js.setAttribute('merchantId', 'YOUR-MERCHANT-ID');
8
js.setAttribute('async', true);
9
js.src = 'https://cdn.kickdynamic.com/kd-lynx-v1.js';
10
var scriptTag = document.getElementsByTagName('script')[0];
11
scriptTag.parentNode.insertBefore(js, scriptTag);
12
})();
13
</script>
Copied!

purchase

The purchase command, makes it possible to track purchases in your web store. It must be called whenever a purchase is made, passing the order identifier, the list of purchased items, the quantities and prices of each order.

Decription

Reports a purchase event.

Placement

Issue this command on the checkout confirmation page.

Usage

1
["purchase", descriptor]
Copied!

Parameters

Parameter
Type
Description
descriptor
object
The description of the purchase cart with the following properties:
    orderId (string): The unique identifier of the purchase.
    items (array of objects): The items purchased. A purchased item has the following properties:
      item (string): The item's identifier.
      quantity (number): The quantity of the item purchased.
      price (number): The item's price.
      uniqueItemId(string): The item's unique identifier.

Example

JavaScript
HTML
1
kd.push(["purchase", {
2
"orderId": "786222",
3
"items": [
4
{"item": "item_1", "price": 99.9, "quantity": 1, "uniqueItemId":"item_1-010"},
5
{"item": "item_2", "price": 39.7, "quantity": 4, "uniqueItemId":"item_2-022"}
6
]
7
}]);
8
// Send the data to LYNX.
9
// Should be the last call on the page, called only once.
10
kd.push(["submit"]);
Copied!
1
<script>
2
var kd = kd || [];
3
(function() {
4
var scriptId = 'kd-js-api';
5
if (document.getElementById(scriptId)) return;
6
var js = document.createElement('script'); js.id = scriptId;
7
js.setAttribute('merchantId', 'YOUR-MERCHANT-ID');
8
js.setAttribute('async', true);
9
js.src = 'https://cdn.kickdynamic.com/kd-lynx-v1.js';
10
var scriptTag = document.getElementsByTagName('script')[0];
11
scriptTag.parentNode.insertBefore(js, scriptTag);
12
})();
13
</script>
Copied!

rate

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

Description

Reports the user's rating for an item.

Placement

Issue this command on the item's rating confirmation page.

Usage

1
['rate', itemId, value]
Copied!

Parameters

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

Example

JavaScript
HTML
1
kd.push(['rate', 'item-23', 4]);
2
// Send the data to LYNX.
3
// Should be the last call on the page, called only once.
4
kd.push(['submit']);
Copied!
1
<script>
2
var kd = kd || [];
3
(function() {
4
var scriptId = 'kd-js-api';
5
if (document.getElementById(scriptId)) return;
6
var js = document.createElement('script'); js.id = scriptId;
7
js.setAttribute('merchantId', 'YOUR-MERCHANT-ID');
8
js.setAttribute('async', true);
9
js.src = 'https://cdn.kickdynamic.com/kd-lynx-v1.js';
10
var scriptTag = document.getElementsByTagName('script')[0];
11
scriptTag.parentNode.insertBefore(js, scriptTag);
12
})();
13
</script>
Copied!

setCustomerId

Description

Sets your customer identifier for known visitors.

Placement

Issue this command when you are able to identify the current visitor (e.g. After login).

Usage

1
['setCustomerId',customerId]
Copied!

Parameters

Parameter
Type
Description
customerId
string
Your unique customer identifier

Example

JavaScript
HTML
1
kd.push(['setCustomerId', '1234ABC78']);
Copied!
1
<script>
2
var kd = kd || [];
3
(function() {
4
var scriptId = 'kd-js-api';
5
if (document.getElementById(scriptId)) return;
6
var js = document.createElement('script'); js.id = scriptId;
7
js.setAttribute('merchantId', 'YOUR-MERCHANT-ID');
8
js.setAttribute('async', true);
9
js.src = 'https://cdn.kickdynamic.com/kd-lynx-v1.js';
10
var scriptTag = document.getElementsByTagName('script')[0];
11
scriptTag.parentNode.insertBefore(js, scriptTag);
12
})();
13
</script>
Copied!

submit

Description

Executes commands stored in the command queue.

Placement

submit should be issued once on every page of the website.

Usage

1
['submit']
Copied!

Parameters

No parameters.

Example

JavaScript
HTML
1
kd.push(['view', 'item_32']);
2
// Send the data to LYNX.
3
// Should be the last call on the page, called only once.
4
kd.push(['submit']);
Copied!
1
<script>
2
var kd = kd || [];
3
(function() {
4
var scriptId = 'kd-js-api';
5
if (document.getElementById(scriptId)) return;
6
var js = document.createElement('script'); js.id = scriptId;
7
js.setAttribute('merchantId', 'YOUR-MERCHANT-ID');
8
js.setAttribute('async', true);
9
js.src = 'https://cdn.kickdynamic.com/kd-lynx-v1.js';
10
var scriptTag = document.getElementsByTagName('script')[0];
11
scriptTag.parentNode.insertBefore(js, scriptTag);
12
})();
13
</script>
Copied!

view

The view command, makes it possible to track which products your visitors view in your website. It has to be called on the product pages your visitors open and should pass the item identifier of the displayed products.

Description

Reports a product view.

Placement

Issue this command on product pages.

Usage

1
["view", itemId]
Copied!

Parameters

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

Example

JavaScript
HTML
1
kd.push(["view", "item_32"]);
2
// Send the data to LYNX.
3
// Should be the last call on the page, called only once.
4
kd.push(["submit"]);
Copied!
1
<script>
2
var kd = kd || [];
3
(function() {
4
var scriptId = 'kd-js-api';
5
if (document.getElementById(scriptId)) return;
6
var js = document.createElement('script'); js.id = scriptId;
7
js.setAttribute('merchantId', 'YOUR-MERCHANT-ID');
8
js.setAttribute('async', true);
9
js.src = 'https://cdn.kickdynamic.com/kd-lynx-v1.js';
10
var scriptTag = document.getElementsByTagName('script')[0];
11
scriptTag.parentNode.insertBefore(js, scriptTag);
12
})();
13
</script>
Copied!

Last modified 3mo ago