# "Product option changed" event

### `Ecwid.OnProductSelectedOptionsChanged`

Track selected options changes for the **currently opened product**.&#x20;

Any option change creates a snapshot of all product options and their currently selected values. Callback from this method allows you to get snapshots before and after the option change alongside the product ID.&#x20;

Code example:

```javascript
Ecwid.OnProductSelectedOptionsChanged.add((payload) => {
  console.log(payload.productId);
  console.log(payload.previousOptions);
  console.log(payload.newOptions);
});

// prints
// {
//   "productId":689454040,
//   "previousOptions":{"Size":"32"},
//   "newOptions":{"Size":"32","Color":"Black"}
// }
```

Payload values:

<table><thead><tr><th width="197">Field</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td>productId</td><td>number</td><td>Customer's email.</td></tr><tr><td>previousOptions</td><td>object</td><td>JSON object with <strong>previously selected</strong> options, where all option names and values are stringified.</td></tr><tr><td>newOptions</td><td>object</td><td>JSON object with <strong>currently selected</strong> options, where all option names and values are stringified.</td></tr></tbody></table>


---

# 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.ecwid.com/storefronts/track-storefront-events/product-option-changed-event.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.
