# Events

Sending events to different channels is easy with EdgeTag. Events can be anything really: clicking on a button, submitting a form, typing in input, page load, text hover, etc.

To ensure we can support multiple channels without requiring you to worry about the payloads and the specific needs of each channel, we have created [standard events](/overview/standard-events.md). This approach enables us to precisely identify the data we receive on the platform and how to transform it in real-time before sending it to its final destinations.

### Parameters

| Name      | Type                                                                        | Required | Description                                                                                       |
| --------- | --------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------- |
| name      | String                                                                      | Yes      | Name of the event that you are capturing.                                                         |
| data      | Record\<string, any>                                                        | No       | Additional data that you would like to send as part of the event.                                 |
| providers | Record\<string, boolean>                                                    | No       | Define for which providers you would like to send this event. By default, we send to all of them. |
| options   | <p>{<br>method?: 'beacon',<br>sync?: true,<br>destination?: string<br>}</p> | No       | See below                                                                                         |

#### Options

**Method**: If you provide the method with a value `beacon`, we will send this event through a [beacon](https://developer.mozilla.org/en-US/docs/Web/API/Beacon_API) delivery mechanism instead of a regular fetch.

**Sync**: Setting sync to true will cause the request to wait for all channels to complete their actions before responding. This may lead to more canceled events in browsers, as some channels might need more time to respond.

**Destination**: We recommend specifying the destination, especially if multiple EdgeTag instances exist on the website. If you do not, we will trigger the same event to multiple destinations. The destination value should be the EdgeTag URL.

### Examples

{% code title="simple PageView" %}

```javascript
edgetag('tag', 'PageView')
```

{% endcode %}

{% code title="AddToCart with a payload" %}

```javascript
edgetag('tag', 'AddToCart', { value: 10.0, currency: 'USD' })
```

{% endcode %}

{% code title="PageView which we only want to send to Meta channel" %}

```javascript
edgetag('tag', 'PageView', {}, { facebook: true })
```

{% endcode %}

{% code title="PageView where you define to which destination it should be send" %}

```javascript
edgetag('tag', 'PageView', {}, {}, { destination: 'https://d.domain.com' })
```

{% endcode %}


---

# Agent Instructions: 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.edgetag.io/implementation/browser/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.
