# Popin 3P Events Documentation

Popin provides JavaScript events via `window.popinEvent` to help track user actions, permissions, and call activities on the widget.

***

### 🔧 Integration

Place the following snippet **below** the Popin integration script:

```javascript
window.popinEvent = (event, data) => {
  if (event === "popin_captured") {
    // Example: Call FB event function here
    fbq("trackCustom", "popinCapture", {
      name: data.name,
      mobile: data.mobile,
    });
  }
};
```

Each event is triggered with a specific payload. You can integrate these events with your analytics, backend systems, or third-party tools.

***

### 📘 Event Reference

#### 1. `nudge_show`

**Description:** Triggered when a nudge popup is displayed to the user.

**Payload:**

```json
{
  "uid": "string"
}
```

***

#### 2. `nudge_open`

**Description:** Triggered when the user opens the nudge popup.

**Payload:**

```json
{
  "uid": "string"
}
```

***

#### 3. `nudge_close`

**Description:** Triggered when the user closes the nudge popup.

**Payload:**

```json
{
  "uid": "string"
}
```

***

#### 4. `popin_permission_given`

**Description:** Triggered when the user grants microphone and/or camera permissions.

**Payload:**

```json
{
  "uid": "string",
  "audio": "boolean",
  "video": "boolean"
}
```

***

#### 5. `popin_permission_denied`

**Description:** Triggered when the user denies microphone and/or camera permissions.

**Payload:**

```json
{
  "uid": "string",
  "audio": "boolean",
  "video": "boolean"
}
```

***

#### 6. `popin_expert_busy`

**Description:** Triggered when the expert is busy and cannot take the call.

**Payload:**

```json
{
  "uid": "string"
}
```

***

#### 7. `popin_rating_done`

**Description:** Triggered when the user submits a rating and optional feedback after a call.

**Payload:**

```json
{
  "uid": "string",
  "rating": "integer",
  "comment": "string"
}
```

***

#### 8. `popin_schedule_created`

**Description:** Triggered when the user schedules a call.

**Payload:**

```json
{
  "uid": "string",
  "timezone": "string",
  "time": "string"
}
```

***

#### 9. `popin_call_end`

**Description:** Triggered when a call ends.

**Payload:**

```json
{
  "uid": "string",
  "callId": "string",
  "invited": "boolean"
}
```

***

#### 10. `popin_captured`

**Description:** Triggered when a new user/lead is captured via the widget.\
Empty or null fields are automatically filtered out.

**Payload:**

```json
{
  "name": "string",
  "email": "string",
  "country": "string",
  "mobile": "string",
  "city": "string",
  "pin_code": "string",
  "group": "string",
  "uid": "string"
}
```

***

#### 11. `popin_navigated`

**Description:** Triggered when the user navigates to different screens.

**Payload:**

```json
{
  "uid": "string",
  "screen": "string"
}
```

**📺 Available Screens:**

| Screen Constant               | Description                                                   |
| ----------------------------- | ------------------------------------------------------------- |
| `SCREEN_CAPTURE_USER_INFO`    | Screen that captures user info like name, number, email, etc. |
| `SCREEN_CONNECT_OR_SCHEDULE`  | Screen to choose live call or scheduling a call.              |
| `SCREEN_CONNECT_GATE_QUEUE`   | Permission screen.                                            |
| `SCREEN_SCHEDULE_CALLBACK`    | Callback booking screen.                                      |
| `PRODUCT_CART`                | Cart page to add products.                                    |
| `SCREEN_EVENT_LIST`           | Lists all events.                                             |
| `SCREEN_RECENT_PRODUCTS`      | Shows recently viewed and other products.                     |
| `SCREEN_SCHEDULE_CALENDAR`    | Lets users pick a date and time.                              |
| `SCREEN_FAQ_VIEW`             | Frequently Asked Questions view.                              |
| `SCREEN_ASK_QUESTION_INPUT`   | Input screen for posting a question.                          |
| `SCREEN_ASK_QUESTION_CONFIRM` | Confirmation screen after posting a question.                 |
| `SCREEN_FAQ_SELECTIVE`        | Allows users to select a video FAQ to play.                   |
| `SCREEN_RETURNING_USER`       | Seen when a customer reopens after a call.                    |
| `SCREEN_SCHEDULE_SLOTS`       | Selects time slot for call scheduling.                        |
| `SCREEN_EXPERTS_BUSY`         | Displayed when all experts are busy.                          |
| `SCREEN_VIDEO_CALL`           | Video calling screen.                                         |
| `SCREEN_CHAT`                 | Chat window with an agent.                                    |
| `SCREEN_REVIEW_AGENT`         | Post-call review screen.                                      |
| `SCREEN_SCHEDULE_WAITING`     | Shown after scheduling when reopened.                         |
| `SCREEN_INVITE_CALL_EXPIRED`  | Displayed when joining an expired group call.                 |

***

#### 12. `popin_auto_captured`

**Description:** Triggered on auto-capture or logged-in flows.

**Payload:**

```json
{
  "uid": "string",
  "captured": "object"
}
```

***

#### 13. `popin_open`

**Description:** Triggered when the Popin widget opens.

**Payload:**

```json
{
  "uid": "string"
}
```

***

#### 14. `popin_close`

**Description:** Triggered when the Popin widget closes.

**Payload:**

```json
{
  "uid": "string"
}
```

***

### 📝 Notes

* All events include a `uid` field that identifies the user session.
* Payloads may vary depending on:
  * User input
  * Permissions granted
  * Widget configuration
* Handle **optional fields gracefully** — they may be omitted if not provided by the user.
