# E-commerce events sent to Google Analytics

Once Google Tag Manager is integrated into your booking module, YoPlanning automatically triggers the following e-commerce events if you activate them in your back office.

***

### 📦 `view_item`

Triggered when clicking on a product detail.

**Data sent**:

* `item_name` (product name)

***

### 🛒 `add_to_cart`

Triggered when adding a session or gift voucher (GBV) to the cart.

**Data sent**:

```json
{
  "currency": "EUR",
  "value": 150,
  "items": [
    {
      "item_name": "Canoë 3h",
      "item_variant": "session",
      "quantity": 2
    }
  ]
}
```

***

### 💳 `begin_checkout`

Triggered when clicking "Pay" on the last page.

**Data sent**:

```json
{
  "currency": "EUR",
  "value": 180,
  "cart_id": "YO123456"
}
```

***

### ✅ `purchase`

Triggered at the end of payment. Two modes exist depending on the type of booking module integration.

***

#### 🔗 **Direct Access** Mode

* The event is automatically triggered at the end of the payment.
* No additional configuration is required.

***

#### 🧩 **iframe** mode

If the module is integrated via an iframe on your site:

* You must define a **success URL** in your module configuration in YoPlanning.
* This URL must be:
  * on the **same domain** as your site (eg: `example.com/merci`)
  * and **include the YoPlanning integration script** (even if no module is displayed on this page)

Thanks to this redirection, the `purchase` event is successfully sent in the background.

***

#### 🧾 Data sent with the `purchase` event

```json
{
  "currency": "EUR",
  "value": 240,
  "transaction_id": "YO654321",
  "transaction_source": "Online",
  "items": [
    {
      "item_name": "Randonnée guidée",
      "item_variant": "session",
      "price": 120,
      "quantity": 2
    }
  ]
}
```
