# Standard Events

With the EdgeTag platform, we aim to minimize friction for both customers and developers as much as possible.&#x20;

With that in mind, we created standard events that support the idea of writing code once, and then you can add as many channels/apps/plugins as you would like without changes to payloads. All channels receive the same payload, and we perform transformations for you both on the browser and the server in real-time. This also allows us to make sure that when a channel introduces a change, we handle it for you.

All parameters are optional, except those marked as required. We will generate an `eventId` automatically for you.

You can also add additional properties to the standard payload, but keep in mind that some channels will not support it.

{% hint style="warning" %}
The following examples are provided for demonstration purposes only, illustrating how the payload should appear. You need to **REPLACE** example data with dynamic values from your website.
{% endhint %}

### PageView

This is the default pixel tracking page for visits.

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

### ViewContent

A visit to a web page you care about (for example, a product page or landing page). ViewContent tells you if someone visits a web page's URL, but not what they see or do on that page.

| Name     | Type                     | Required | Description                                                                                                 |
| -------- | ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency | string                   | no       | The currency for the value specified                                                                        |
| value    | number                   | no       | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| contents | [Content\[\]](#contents) | no       | A list of products or items related to this event                                                           |

```javascript
edgetag('tag', 'ViewContent', {
  currency: 'USD',
  value: 10.50,
  contents: [{
    id: '123123123',
    quantity: 1,
    item_price: 10.50,
    title: 'Summer Fun',
    category: 'bracelets',
    image: 'https://mysite.com/product/fun-main.jpg',
    url: 'https://mysite.com/summer-fun'
  }]
})
```

### AddToCart

When a product is added to the shopping cart.

| Name        | Type                     | Required | Description                                                                                                 |
| ----------- | ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency    | string                   | Yes      | The currency for the value specified                                                                        |
| value       | number                   | Yes      | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| contents    | [Content\[\]](#contents) | No       | A list of products or items related to this event                                                           |
| checkoutUrl | string                   | No       | Url to go to the checkout page                                                                              |

```javascript
edgetag('tag', 'AddToCart', {
  currency: 'USD',
  value: 10.50,
  checkoutUrl: 'http://www.example.com/path/to/checkout',
  contents: [{
    id: '123123123',
    quantity: 1,
    item_price: 10.50,
    title: 'Summer Fun',
    category: 'bracelets',
    image: 'https://mysite.com/product/fun-main.jpg',
    url: 'https://mysite.com/summer-fun'
  }]
})
```

### RemoveFromCart

When a product is removed from the shopping cart.

| Name        | Type                     | Required | Description                                                                                                 |
| ----------- | ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency    | string                   | Yes      | The currency for the value specified                                                                        |
| value       | number                   | Yes      | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| contents    | [Content\[\]](#contents) | No       | A list of products or items related to this event                                                           |
| checkoutUrl | string                   | No       | Url to go to the checkout page                                                                              |

```javascript
edgetag('tag', 'RemoveFromCart', {
  currency: 'USD',
  value: 10.50,
  checkoutUrl: 'http://www.example.com/path/to/checkout',
  contents: [{
    id: '123123123',
    quantity: 1,
    item_price: 10.50,
    title: 'Summer Fun',
    category: 'bracelets',
    image: 'https://mysite.com/product/fun-main.jpg',
    url: 'https://mysite.com/summer-fun'
  }]
})

```

### InitiateCheckout

When a person enters the checkout flow before completing the checkout process.

| Name        | Type                     | Required | Description                                                                                                 |
| ----------- | ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency    | string                   | Yes      | The currency for the value specified                                                                        |
| value       | number                   | Yes      | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| contents    | [Content\[\]](#contents) | No       | A list of products or items related to this event                                                           |
| checkoutUrl | string                   | No       | Url to go to the checkout page                                                                              |

```javascript
edgetag('tag', 'InitiateCheckout', {
  currency: 'USD',
  value: 20.50,
  checkoutUrl: 'http://www.example.com/path/to/checkout',
  contents: [
    {
      id: '123123123',
      quantity: 1,
      item_price: 10.50,
      title: 'Summer Fun',
      category: 'bracelets',
      image: 'https://mysite.com/product/fun-main.jpg',
      url: 'https://mysite.com/summer-fun'
    },
    {
      id: '4423434343',
      quantity: 2,
      item_price: 5,
      title: 'Summer Shorts',
      category: 'shorts',
      image: 'https://mysite.com/product/shorts-main.jpg',
      url: 'https://mysite.com/summer-shorts'
    }
  ]
})
```

### AddShippingInfo

When the user has submitted their shipping information.

| Name     | Type                      | Required | Description                                                                                                 |
| -------- | ------------------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency | string                    | Yes      | The currency for the value specified                                                                        |
| value    | number                    | Yes      | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| contents | [Contents\[\]](#contents) | No       | A list of products or items related to this event                                                           |

```javascript
edgetag('tag', 'AddShippingInfo', {
  currency: 'USD',
  value: 20.50,
  contents: [
    {
      id: '123123123',
      quantity: 1,
      item_price: 10.50,
      title: 'Summer Fun',
      category: 'bracelets',
      image: 'https://mysite.com/product/fun-main.jpg',
      url: 'https://mysite.com/summer-fun'
    },
    {
      id: '4423434343',
      quantity: 2,
      item_price: 5,
      title: 'Summer Shorts',
      category: 'shorts',
      image: 'https://mysite.com/product/shorts-main.jpg',
      url: 'https://mysite.com/summer-shorts'
    }
  ]
})
```

### AddPaymentInfo

When payment information is added to the checkout flow.

| Name     | Type                     | Required | Description                                                                                                 |
| -------- | ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency | string                   | Yes      | The currency for the value specified                                                                        |
| value    | number                   | Yes      | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| contents | [Content\[\]](#contents) | No       | A list of products or items related to this event                                                           |

```javascript
edgetag('tag', 'AddPaymentInfo', {
  currency: 'USD',
  value: 20.50,
  contents: [
    {
      id: '123123123',
      quantity: 1,
      item_price: 10.50,
      title: 'Summer Fun',
      category: 'bracelets',
      image: 'https://mysite.com/product/fun-main.jpg',
      url: 'https://mysite.com/summer-fun'
    },
    {
      id: '4423434343',
      quantity: 2,
      item_price: 5,
      title: 'Summer Shorts',
      category: 'shorts',
      image: 'https://mysite.com/product/shorts-main.jpg',
      url: 'https://mysite.com/summer-shorts'
    }
  ]
})
```

### Purchase

When a purchase is made or the checkout flow is completed.

{% hint style="info" %}
We suggest that for the Purchase event, you provide `eventId` which matches `orderId`. This way, if you are sending Purchase events from any other system, channels can de-duplicate them.
{% endhint %}

| Name         | Type                      | Required | Description                                                                                                  |
| ------------ | ------------------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| currency     | string                    | Yes      | The currency for the value specified                                                                         |
| value        | number                    | Yes      | A numeric value associated with this event. This could be a monetary value or a value in some other metric.  |
| contents     | [Content\[\]](#contents)  | No       | A list of products or items related to this event                                                            |
| orderId      | string                    | Yes      | The order ID for the transaction.                                                                            |
| discounts    | [Discount\[\]](#discount) | No       | The discount codes utilized for the transaction                                                              |
| grossValue   | number                    | No       | A number representing the gross value for the value metric. Used for channels configured to use gross value. |
| taxCost      | number                    | No       | A number representing the tax cost for the value metric. Used to calculate net value if configured.          |
| shippingCost | number                    | No       | A number representing the shipping cost for the value metric. Used to calculate net value if configured.     |

```javascript
edgetag('tag', 'Purchase', {
  currency: 'USD',
  value: 20.50,
  orderId: '190315',
  eventId: '190315',
  discounts: [
    {
      code: 'OFF20',
      value: '20',
      type: 'PERCENTAGE'
    },
    {
      code: 'BONUS150',
      value: '150',
      type: 'FLAT'
    }
  ],
  contents: [
    {
      id: '123123123',
      quantity: 1,
      item_price: 10.50,
      title: 'Summer Fun',
      category: 'bracelets',
      image: 'https://mysite.com/product/fun-main.jpg',
      url: 'https://mysite.com/summer-fun'
    },
    {
      id: '4423434343',
      quantity: 2,
      item_price: 5,
      title: 'Summer Shorts',
      category: 'shorts',
      image: 'https://mysite.com/product/shorts-main.jpg',
      url: 'https://mysite.com/summer-shorts'
    }
  ]
})
```

### Subscribe

When a person applies to start a paid subscription for a product or service you offer.

| Name     | Type   | Required | Description                                                                                                 |
| -------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency | string | No       | The currency for the value specified                                                                        |
| value    | number | No       | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| sourceId | string | No       | The unique identifier of the sign-up source.                                                                |

```javascript
edgetag('tag', 'Subscribe', {
  sourceId: 'Email',
  currency: 'USD',
  value: 49.99
})
```

### Search

When a search is made.

| Name     | Tyep                     | Required | Description                                                                                                 |
| -------- | ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency | string                   | No       | The currency for the value specified                                                                        |
| value    | number                   | No       | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| contents | [Content\[\]](#contents) | No       | A list of products or items related to this event                                                           |
| search   | string                   | No       | A search query made by a user.                                                                              |

```javascript
edgetag('tag', 'Search', {
  currency: 'USD',
  value: 10.50,
  search: 'summer',
  contents: [{
    id: '123123123',
    quantity: 1,
    item_price: 10.50,
    title: 'Summer Fun',
    category: 'bracelets',
    image: 'https://mysite.com/product/fun-main.jpg',
    url: 'https://mysite.com/summer-fun'
  }]
})
```

### Lead

When a sign-up is completed.

| Name     | Type   | Required | Description                                                                                                 |
| -------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| currency | string | No       | The currency for the value specified                                                                        |
| value    | number | No       | A numeric value associated with this event. This could be a monetary value or a value in some other metric. |
| name     | string | No       | Title of the product/page                                                                                   |
| category | string | No       | Category of the Item.                                                                                       |

```javascript
edgetag('tag', 'Lead', {
  category: 'offers',
  name: 'Special Offer',
  currency: 'USD',
  value: 49.99
})
```

### Type Definitions

#### Content

| Name        | Type                      | Required | Description                                                                            |
| ----------- | ------------------------- | -------- | -------------------------------------------------------------------------------------- |
| id          | string                    | Yes      | Id of the Item. Like Product ID                                                        |
| quantity    | number                    | Yes      | Quantity of the Item.                                                                  |
| item\_price | number                    | Yes      | Final price per unit of the content/product.                                           |
| variantId   | string                    | No       | Variation Id of the Item. Required if variant id is used as content id for any channel |
| sku         | string                    | No       | SKU of the Item. Required if sku is used as content id for any channel                 |
| title       | string                    | No       | Title of the listed Item.                                                              |
| description | string                    | No       | Product description used for the item.                                                 |
| category    | string                    | No       | Category of the Item. Comma separated                                                  |
| brand       | string                    | No       | Brand of the Item.                                                                     |
| type        | product \| product\_group | No       | Type of the item.                                                                      |
| image       | string                    | No       | Image URL of this Item.                                                                |
| url         | string                    | No       | URL of this Item.                                                                      |

#### Discount

| Name  | Type               | Required | Description                                                 |
| ----- | ------------------ | -------- | ----------------------------------------------------------- |
| code  | string             | Yes      | Code that was applied for the discount                      |
| type  | FLAT \| PERCENTAGE | No       | What was the discount type: flat amount or percentage based |
| value | string             | No       | Value that was applied for that discount code               |

### Additional Parameters

You can use the parameters below with every event. You need to add them in the payload/data parameter.

| Name               | Type              | Description                                                                                                                                 |
| ------------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| eventId            | string            | By default we generate a unique id for every event. If you want to pass your own id, you can use this parameter.                            |
| skipIPAddress      | boolean           | You can use this flag if you are sending offline event where you do not know IP of the user.                                                |
| source             | online \| offline | Define source of the event. By default we send online.                                                                                      |
| skipTransformation | boolean           | If you pass this flag, we will not transform/normalize your data. You will need to take care of this as we will just pass through the data! |

```javascript
edgetag('tag', 'Lead', {
  category: 'offers',
  name: 'Special Offer',
  currency: 'USD',
  value: 49.99,
  source: 'offline',
  skipIPAddress: true
})
```


---

# 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/overview/standard-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.
