# Google Analytics 4.

> Source: https://docs.gifty.nl/en/order-widget/installation/analytics
> Language: en

The GA4 integration sends a purchase event directly to your Google Analytics property. This event contains the total gift card value and details about the purchased products.

---

<a id="installation"></a>

## Installation

To enable GA4 purchase tracking, add the gtag property to your Gifty script:

```html
<script>
window.Gifty = {
  key: 'WIDGET_KEY_HERE',
  gtag: true
};
(function (e, t) {
	var n = e.createElement(t);
	n.async = true;
	n.src = 'https://static.gifty.nl/js/widget.js';
	var r = e.getElementsByTagName(t)[0];
	r.parentNode.insertBefore(n, r);
})(document, 'script');
</script>
```

---

<a id="events"></a>

## Event details

When a customer completes an order, we send a **purchase** event as below.

```js
gtag("event", "purchase", {
  transaction_id: "or_E04koXGzj8dl92nb1ywQZgx5",
  value: 185,
  tax: 0.00,
  shipping: 0.00,
  currency: "EUR",
  items: [
    {
      item_id: "gifty-gift-card",
      item_name: "Gifty Gift Card",
      item_variant: "Package: Gifty hoodie (1)",
      price: 35,
      quantity: 1
    },
    {
      item_id: "gifty-gift-card",
      item_name: "Gifty Gift Card",
      item_variant: "Value: 7500",
      price: 75,
      quantity: 2
    }
  ]
})
```

The included details are described in the table below.

| Field | Description |
| --- | --- |
| transaction_id | Unique Gifty order ID |
| value | Total value of all gift cards in the order. Note that additional items like wrappings and shipping are excluded on purpose, as this does not count towards your revenue. |
| currency | Currency of the order (for example EUR) |
| items | All gift cards in the order |
