# Sending Add to Cart-Events

Usually adding an Add to cart button directly into the recommendation which lists multiple products is fairly straightforward, the website just needs to have an appropriate javascript function to do the operation. Nosto provides ready-made functions for multiple platforms so check the Nosto documentation specific to your e-commerce platform or if needed look into your e-commerce platform's documentation and support on how to create such a function.

Once the Add to cart button is pressed it should call that function to add the products to the cart, but it should also additionally let Nosto know that the button was pressed so Nosto can track the sales from the recommendation. When using the JS API this attribution can be done with the `recommendedProductsAddedToCart`-function as follows:

```javascript
nostojs(api => {
  api.recommendedProductAddedToCart("productId1", "nosto-categorypage-1");
});
```

⚠️ The api call is only for informing Nosto about the attribution (that the product was added from the recommendation), normal cart tagging should be used to tell Nosto the user’s cart contents.

{% hint style="info" %}
To learn more about the `recommendedProductAddedToCart` usage, please refer to the [official API documentation](https://nosto.github.io/nosto-js/interfaces/client.API.html#reportaddtocart).

`recommendedProductAddedToCart` is an alias for `reportAddToCart`
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nosto.com/techdocs/apis/frontend/js-apis/recommendations/sending-add-to-cart-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
