> For the complete documentation index, see [llms.txt](https://docs.ecwid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecwid.com/storefronts/track-storefront-events/product-option-changed-event.md).

# "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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ecwid.com/storefronts/track-storefront-events/product-option-changed-event.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
