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.

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:

  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'
    }
  });


 

Was this article helpful?