> For the complete documentation index, see [llms.txt](https://docs.firework.com/firework-for-developers/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/add-to-cart.md).

# Add to cart

The following describes how add to cart tracking is done for Firework.

## How to implement the "add\_to\_cart" tracking event

```javascript
<script>
function onAddToCart() {
    window._fwn.analytics.addToCart({
        "order_id": "123456789",
        "currency": "USD",
        "subtotal": "40.00",
        "total_discounts": "5.00",
        "order_value": "50.00",
        "line_items": [{
                "sku": "TSHIRT-RED-M",
                "quantity": 2,
                "price": "15.00",
                "name": "Red T-shirt (M)"
            },
            {
                "sku": "BANANA",
                "quantity": 10,
                "price": "1.00",
                "name": "Organic Banana"
            }
        ]

    });
}

// Calls onAddToCart() whenever there is add to cart happening
</script>
```

Note: Please refer to the [payload section](/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/purchase.md#payload-for-purchase-tags) for the required fields.
