Attraqt
Search…
Add to Cart
When your user decides to add a product to cart, you should send an add-to-cart action. Add to cart actions are mostly used to calculate add to cart (or add to basket) conversion rates. You should send an add to cart event for each product the user adds to their cart and specify the quantity of the product added in the metadata.

Lister page

When the add to cart comes from navigation result page or a search result page, rather than from a product detail page, we consider this as adding to cart from a lister page. See example:
1
const addToCartAction = {
2
"action":"add-to-cart",
3
"target": {
4
"product":"83647582"
5
},
6
"metadata": {
7
"quantity": 1,
8
"locale": "en_GB"
9
},
10
"sourceId": "5f0dfaf1-c79a-47fd-982f-b17de6533cf3" // optional, see below
11
}
12
xo.activity.send(addToCartAction);
Copied!
The properties needed for sending an add to cart event from a lister page are as follows:
  • action - you need to specify the action as add-to-cart
  • target.product - you need to specify the product id that is added to cart. If you are implementing an FHR integration, this would be equal to the secondId available in the FHR query response.
  • metadata.quantity - you need to specify the quantity of the item added in the basket.
  • sourceId - if you are implementing an FHR integration you should send over the source id of the page which corresponds to the responseId **from the FHR query** response.
  • locale - the locale selected by the user.
Any additional information you wish to send(other than quantity) can also be included in the metadata _**_object.
Important! Don't forget, you need to send a separate event for every item.

Product detail page

When the add to cart comes from a product detail page, you should omit the source id. See example:
1
const addToCartAction = {
2
"action":"add-to-cart",
3
"target": {
4
"product":"83647582"
5
},
6
"metadata": {
7
"quantity": 1,
8
"locale": "en_GB"
9
}
10
}
11
xo.activity.send(addToCartAction);
Copied!
The properties needed for sending an add to cart event from a product detail page are as follows:
  • action - you need to specify the action as add-to-cart
  • target.product - you need to specify the product id that is added to cart. If you are implementing an FHR integration, this would be equal to the secondId available in the FHR query response.
  • metadata.quantity - you need to specify the quantity of the item added in the basket.
  • locale - the locale selected by the user.
Any additional information you wish to send(other than quantity) can also be included in the metadata _**_object.
Last modified 21d ago