> For the complete documentation index, see [llms.txt](https://docs.salesmonk.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.salesmonk.ai/setup/javascript-events.md).

# JavaScript Events

The **SaaSMonk Chat Widget** tracks and emits the following JavaScript events through the lifecycle of the chat experience. These can be captured using a sample message listener like the following to be used for actions like sending event to Google Analytics, Pixel, etc.

```javascript
window.addEventListener("message", (ev) => {
  if (ev.data.type == "MEETING_BOOKED") {
    // Send to Google Analytics
    dataLayer.push({ event: "meeting_booked" });

    // Send to pixel
    fbq("track", "RevenueHero", { event: "meeting_booked" });
  }
});
```

### MEETING\_BOOKED

The event is sent when a meeting is booked successfully through a calendar integrated within our widget

```json
{
  "type": "MEETING_BOOKED",
  "meeting": {
    "id": "1234",
    "attributes": {
      "booker_name": "John Smith",
      "booker_email": "john.smith@acme.com",
      "phone_number": "+11234567890",
      "booker_company_name": "Acme, Inc",
      "country_code": "US",
      "calendar_type": "calendly",
      "meeting_time": "2023-11-24T05:30:00.000Z",
      "created_at": "2023-11-24T05:30:00.000Z",
      "booking_guests": ["jackie@acme.com"],
      "booked_with_name": "Jane Doe",
      "booked_with_email": "jane@abc.com"
    }
  }
}
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.salesmonk.ai/setup/javascript-events.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.
