<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [BaseXAPI](./x-components.basexapi.md) &gt; [addProductToCart](./x-components.basexapi.addproducttocart.md)

## BaseXAPI.addProductToCart() method

Tracks that a product was added to cart from PDP.

**Signature:**

```typescript
addProductToCart(productId?: string): void;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

productId


</td><td>

string


</td><td>

_(Optional)_ The product id that was added to cart.


</td></tr>
</tbody></table>

**Returns:**

void

