---
title: "Events API"
url: "https://help.webeyez.com/en/article/events-api"
language: "en"
last_updated: "2025-04-20T12:37:09.646Z"
---

# Events API

## **Overview**

This documentation outlines the basic usage of the Webeyez Public Function for manually sending event data. Ensure that the data you send conforms to the payload specifications for each event type to facilitate accurate tracking and analysis by the Webeyez system.

The Webeyez Public Function offers a straightforward way for clients to manually send data to Webeyez. This functionality is particularly useful for tracking specific events or errors that occur within your web application. The data types that can be sent include Goals (such as Ajax requests, Form submissions, Page Views), JavaScript Errors, and Network Calls.

## **Integration**

The Public Function is readily accessible via the global window object in your web application:

window.wzApi.sendEvent

This method allows you to manually send data to Webeyez by passing an object with specific attributes.

## **Usage**

### **Sending an Event**

To send an event, you will need to construct an object with two keys: type and payload. The type key specifies the nature of the event you’re reporting, while the payload key contains the event data.

```plaintext
window.wzApi.sendEvent({
  type: 'event'
  payload: {
    // Event-specific data
  }
});
```

### **Payload Specifications**

Each event type requires a different structure for the payload:

### ***Event***

Use this type to track custom events, and data.

-   event\_name: Name of the event (min 3 characters)  \[Mandatory\]
-   success: A boolean indicating whether the request was successful. \[Mandatory\]
-   request: The request details. \[optional\]
-   response: The response received. \[optional\]
-   method: The HTTP method used (e.g., GET, POST). \[optional\]
-   status\_code: The HTTP status code of the response. \[optional\]
-   error: Any error message associated with the request. \[optional\]
-   duration\_ms: The duration of the request in milliseconds. \[optional\]
-   custom\_data\_name: The name of the custom data. \[optional\]
-   custom\_data\_value: The value of the custom data. \[optional\]

### **Examples**

Sending a custom event:

```plaintext
  wz.API.sendEvent({
    type: 'event',
    payload: {
      event_name: 'Search',
      success: true,
      request: { method: 'GET', url: 'http://example.com/api/search' },
      response: { status: 200, data: { results: [] } },
      method: 'GET',
      status_code: 200,
      error: ‘could not find product’,
      duration_ms: 100,
      custom_data_name: 'Search Query',
      custom_data_value: 'example search'
    }
  });
```
