> ## Documentation Index
> Fetch the complete documentation index at: https://developers.gotolstoy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Events

> Subscribe to JS events from your Tolstoy Widget or Embedded Player

Tolstoy's player uses `window.postMessage()` to post event from the embedded iframe to the parent hosting site, for more information see [Window.postMessage()](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage)

Example of using an event:

```javascript theme={null}
window.addEventListener("message", (message) => {
  if (message.data.name === "tolstoyStarted") {
    console.log("Tolsoty Started", message.data);
  }
});
```

All events will send the event name in the `name` attribute, In addition all events will send:

* `accountId` - Your account ID
* `projectId` - Your project ID
* `anonymousId` - Viewer ID

## Core Events

| Event Name | Description |
| - | - |
| `tolstoyStarted` | Start button clicked for the first time |
| `pageView` | Page viewed |
| `embedView` | Element in view |
| `videoLoaded` | Video starts to play |
| `videoPause` | Video paused |
| `videoResume` | Video resumed |
| `videoReplay` | Video replayed |
| `videoSeeked` | Video seeked |
| `videoUnmuted` | Video unmuted |
| `videoWatched` | Video watched completion event |
| `feedPlay` | Feed started playing |
| `feedPause` | Feed paused |
| `feedScroll` | Swipe to next video |
| `clickViewProduct` | Click to view product details |
| `shareClick` | Share clicked |
| `tolstoyProductCardClick` | Product card clicked |
| `tolstoyAddToCart` | Add to cart triggered |

## Widget Lifecycle Events

| Event Name | Description |
| - | - |
| `tolstoyWidgetReady` | Widget ready |
| `tolstoyWidgetOpen` | Widget opened |
| `tolstoyWidgetClose` | Widget closed |
| `tolstoyModalClose` | Modal closed |

## Interactive Events

| Event Name | Description |
| - | - |
| `tolstoyAnswerClicked` | CTA button clicked |
| `tolstoyInputSubmit` | Form input submitted |
| `tolstoyLeadFormSubmit` | Lead form submitted |
| `tolstoyReachedEnd` | User reached end |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.